Android styles and themes

Source: Internet
Author: User

I,

Style can be applied to view and activity or application.

Application on view: Style = "", application on activity and application: Android: theme = "".

When a view is set with a style, but the attributes in this style are not applicable to this view, this view will simply ignore this parameter.

After Android: theme is used to set a style for the application or activity, each view in it inherits the style by default. If the view has its own style set, the attributes set in theme are overwritten.

Set a style for viewgroup. The view in the style does not apply the attributes in the style.

Style definition: (it can be placed in any file suffixed with ". xml". The file name does not matter, and the style name must be unique)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CodeFont" parent="@android:style/TextAppearance.Medium">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#00FF00</item>
        <item name="android:typeface">monospace</item>
    </style>
</resources>
II,
Note the following points about style inheritance:
1. inherit the built-in style in Platform:
parent="@android:style/TextAppearance.Medium"
2. inherit the defined:
<style name="CodeFont.Red">
  <item name="android:textColor">#FF0000</item>
</style>
Separated by ".", style: codefont. Red inherits from style: codefont.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.