Android Custom window Title style instance _android

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.