Android offers a number of controls that allow developers to design UI-related programs. However, many times, the default UI settings are not sufficient to meet our needs, either not good-looking, or highly inadequate, or are not in harmony with the application interface. This is done through custom styles or custom controls.
Of course, when space is sufficient to meet requirements, it is usually necessary to define the style to be done. This article will briefly describe how to implement the definition window Title through a custom style.
Look at the effect chart first
Progressive Realization
Add the following code to the Res/values/styles.xml file
Copy Code code as follows:
<style name= "Myactivitytheme" parent= "Android:Theme.Light" >
<item name= "Android:windowtitlebackgroundstyle" > @style/windowtitlebackgroundstyle</item>
<item name= "Android:windowtitlestyle" > @style/windowtitlestyle</item>
<!--Window Header Height-->
<item name= "Android:windowtitlesize" >54dp</item>
</style>
<!--preference Settings Window Title-->
<style name= "Windowtitlebackgroundstyle" >
<item name= "Android:background" > #CCE8CF </item>
</style>
<style name= "Windowtitlestyle" >
<item name= "Android:textcolor" > #FF0000 </item>
<item name= "Android:paddingleft" >25dp</item>
<item name= "Android:textsize" >20sp</item>
</style>
To specify an activity or application topic in manifest for the myactivitytheme defined above, use the following example to set up an activity.
Copy Code code as follows:
<activity
Android:name= "Com.example.stylewindowtitle.MainActivity"
Android:label= "@string/app_name"
Android:theme= "@style/myactivitytheme"
>
<!--code goes here-->
Extended Reading
The properties in Android