First, the default titlebar for Android is this
You can do it by yourself (just change it) titlebar your own layout file how to write it.
My layout file is like this:
<?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=" match_parent " android:o rientation= "Horizontal" > <imageview android:id= "@+id/image_titilebar" android:layout_width= " Wrap_content " android:layout_height=" match_parent " android:background=" @drawable/ic_launcher " > </ImageView> <textview android:text= "Options" android:layout_width= "Wrap_content" android:layout_height= "Match_parent" android:textsize= "20sp" android:gravity= "center_vertical " /></linearlayout>
Activity file like this:
Import Android.app.activity;import Android.os.bundle;import Android.view.window;public class MainActivity extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); This.requestwindowfeature (Window.feature_custom_title); Setcontentview (R.layout.activity_main); GetWindow (). Setfeatureint (Window.feature_custom_title,r.layout.titlebar);}}
But at this time does not run correctly, you need in the Androidmanifest file corresponding activity added Android:theme = "xxxx" OK
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Questions about Android Custom TitleBar