The original Android title bar color comparison monotonous, is a black lump, now assume your software needs to add the title bar alone, so not only beautiful but also can be added to the progress bar, how to achieve:
method One , in your activity, add the following code to the OnCreate method:
Requestwindowfeature (window.feature_custom_title);
Setcontentview (r.layout.main); The layout of the software activity
GetWindow (). Setfeatureint (Window.feature_custom_title, R.layout.titlebar); TitleBar for the layout of its own title bar
But the new problem again, this is not the depth of the custom title bar, such as the original height and background have not changed, there is no good way? The answer is yes,
Method Two:
So first define a style, modify the background if you modify the Android:windowtitlebackgroundstyle
If you modify the title bar height, modify the Android:windowtitlesize
Example:
<?xml version= "1.0" encoding= "Utf-8"?> <resources xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
<style name=" Customwindowtitlebackground ">
<item name=" Android:background "># 565656</item>
</style>
<style name= "test" parent= "Android:theme" >
<item name= " Android:windowtitlesize ">50dp</item>
<item name=" Android:windowtitlebackgroundstyle "> @style customwindowtitlebackground</item>
</style>
</resources>
Adding attributes to the activity in the android_manifest.xml of the program Android:theme = "@style/test" is OK.
<?xml version= "1.0" encoding= "Utf-8"?> <manifest xmlns:android=
"http://schemas.android.com/apk/res/" Android "
package=" Com.guardian "
android:versioncode=" 1 "
android:versionname=" 1.0 ">
< Application android:icon= "@drawable/icon" android:label= "@string/app_name" > <activity android:name=
". Test "
android:label=" @string/app_name "
android:theme =" @style/test " //Right here
>
< intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</ application>
<uses-sdk android:minsdkversion= "4"/>
</manifest>
You can then customize the title bar layout by using the custom title bar XML file.