- 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" ?> < 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 styles -<stylename= "Statusbarbackground"><Itemname= "Android:background">@drawable/bitmap_repeat</Item></style><stylename= "Xtheme"Parent= "Android:theme"><!--Window Attributes -<Itemname= "Android:windowtitlebackgroundstyle">@style/statusbarbackground</Item></style><!--Custom Heading styles -</Resources>
4> references the theme android:theme="@style/xtheme" in Manifest.xml
<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"
@Override Public 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
For details, see: http://www.iteye.com/topic/760314
Code: HTTP://PAN.BAIDU.COM/S/1DD1QX01
Second.zip