java - how to put button beside activity titile in android? -


hi want put button beside activity title in android. can change text using settitle() haven't find allows put button beside title of activity. using android 4.0.3. can me?

enter image description here

create xml file in project name topbar.xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="40dp" android:orientation="vertical" android:background="@android:color/white"> <textview android:id="@+id/title_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="mytitle: nameofuser" android:layout_centervertical="true" android:textcolor="@android:color/black" android:textstyle="bold" android:textsize="20sp" android:layout_marginleft="20dp"/> <button android:id="@+id/back_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:text="btn" android:textcolor="@android:color/white" android:layout_marginleft="5dp" android:layout_alignparentright="true"/> </relativelayout> 

and add layout in layout writing:

<include layout="@layout/topbar"/> 

hope you.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -