Many users find that the title bar of their android Program
Titlebar area is monotonous. If you want to personalize it, you can use the following method to customize a layout file for the title of your software, such as the title bar of your browser.
Favicon, custom progress bar, and uncertain progress indicators. The following code is used in oncreate, and the sequence should not be changed; otherwise, it cannot be generated.
Effect: requestwindowfeature (window. feature_custom_title );
Setcontentview (R. layout. Main); // layout of the software Activity
Getwindow (). setfeatureint (window. feature_custom_title, R. layout. titlebar); // titlebar is the layout of its own title bar. Although you can customize the title bar to a certain extent, the height and background of the title bar cannot be changed here (two very ugly borders are displayed at both ends after the background is set ). it is said that the reason is inherent in Android. here is the modification method: the principle is like this. adding a title directly as in the code above only adds a sub-interface to the original title without changing the original attributes, such as the title bar size and title bar background. these need to be defined in theme topics. therefore, define a style first. If you modify the background, modify Android: windowtitlebackgroundstyle. If you modify the title bar height, modify 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> Add the property Android: theme = "@ style/test" to the corresponding activity in the android manifest. xml file of the program. <? 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" type = "codeph" text = "/codeph">
<Application Android: icon = "@ drawable/icon" Android: Label = "@ string/app_name">
<Activity Android: Name = ". Guardian"
Android: Label = "@ string/app_name"
Android: theme = "@ style/test" // here
>
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
</Application>
<Uses-SDK Android: minsdkversion = "4"/>
</Manifest> then, you can customize the title bar layout by setting the custom title bar XML file.