Wednesday, 29 June 2016

Create custom actionBar

 android:textColorHint="@color/hint_color"
 android:background="@android:color/transparent"

To do so, follow those 2 simple steps:

1. Java Code

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.actionbar);
Where R.layout.actionbar is the following XML.

2. XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="YOUR ACTIVITY TITLE"
    android:textColor="#ffffff"
    android:textSize="24sp" />
</LinearLayout>

No comments:

Post a Comment