- Set the title bar background
1> Preparation Background Image: background_pix.png
Note: Using a background image is better than using color to make the background look like a bump.
2> drawable folder XML file
Bitmap_repeat.xml
<?xml version= "1.0" encoding= "Utf-8"? ><bitmap xmlns:android= "Http://schemas.android.com/apk/res/android" android:src= "@drawable/title_pic" android:tilemode= "repeat" > </bitmap>
3> Defining style Files Style.xml
<?xml version= "1.0" encoding= "Utf-8"?><resources><!--custom heading style--><style name= " Statusbarbackground "><item name=" Android:background "> @drawable/bitmap_repeat</item></style ><style name= "Xtheme" parent= "android:theme" ><!--window attributes--><item name= "Android: Windowtitlebackgroundstyle "> @style/statusbarbackground </item></style><!--custom heading style--></ Resources>
4> references the theme android:theme="@style/xtheme" in Manifest.xml
<activity android:name= ". Activity. Mainactivty "android:screenorientation=" Portrait "android:configchanges=" Keyboardhidden|orientation "Android: Theme= "@style/xtheme" ></activity>
- Custom title bar layout file Ct_title.xml
Note: The Ct_title.xml file has the following way to set the title bar background will be out of fill dissatisfaction effect
android:background= "@drawable/bitmap_repeat"
@Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Requestwindowfeature ( Window.feature_custom_title); Setcontentview (R.layout.main); GetWindow (). Setfeatureint (Window.feature_custom_ Title,r.layout.ct_title);}
Reprint Please specify source: http://www.cnblogs.com/yydcdut/p/3694597.html
Android--Customize title bar, fill with background color