Tuesday, 15 September 2015

Customize ActionBar in Android -



Customize ActionBar in Android -

i need customize android actionbar, have read link , interested in effect (you can see in video link), here illustration of sequence:

thanks, ideas appreciated.

simply hide action bar , create oun custom action bar , include action bar in layouts.

to hide action bar requestwindowfeature(window.feature_no_title); utilize code before before setcontentview

super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); // code hide action bar form ui setcontentview(r.layout.mailactivity);

now create own custom action bar custom_actionbar.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="50dp" android:background="#caefee" android:orientation="horizontal" > <imagebutton android:id="@+id/home" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/home" android:contentdescription="@string/home" android:background="@null" android:layout_margin="10dp" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:text="@string/home" /> <textview android:id="@+id/titletext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margin="10dp" android:text="@string/app_name" android:textsize="25sp" /> <imagebutton android:id="@+id/settings" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:background="@null" android:layout_margin="10dp" android:contentdescription="@string/settings" android:src="@drawable/settings" android:text="@string/settings" /> </relativelayout>

here mention height of custom action bar. add together ui this

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#e5fafb" > <include layout="@layout/custom_actionbar"/> // code add together custom action bar layout <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_margintop="50sp" android:textcolor="#000000" android:textsize="30sp" android:textstyle="bold" android:text="@string/textview1" /> </relativelayout>

it may help you.

android android-actionbar

No comments:

Post a Comment