<p></p> <p>1. 继承: 在运用系统自带的风格时只想改变其中一些小的方面,当然,我们可以直接在布局文件中控件的属性里重写这个属性即可。因为在布局文件中定义的属性的优先级>我们在style中定义的属性。</p> <pre><style name="GreenText" parent="@android:style/TextAppearance"><br />        <item name="android:textColor">#00FF00</item><br /></style></pre>
若是继承自己定义的style时可以使用下面格式,继承于CodeFont.但不适用于继承系统自带的style
<pre><style name="CodeFont.Red"><br />        <item name="android:textColor">#FF0000</item><br /></style></pre>
<p>2.  style内容:可以上Android developer查找特定类的XML attributes,还有些属性是不属于任何view,只属于window的.</p>
<blockquote> <p>However, if you apply a style to a View that does not support all of the style properties, the View will apply only those properties that are supported and simply ignore the others.</p> </blockquote>
<p>你所定义的style,并不一定适用于所有的视图,有些属性试图并不支持,这个时候,视图将只会运用它所支持的属性,忽略掉剩下的属性.</p>
<p>3. 应用style:</p>
<pre><color name="custom_theme_color">#b0b0ff</color><br /><style name="CustomTheme" parent="android:Theme.Light"><br />    <item name="android:windowBackground">@color/custom_theme_color</item><br />    <item name="android:colorBackground">@color/custom_theme_color</item><br /></style></pre>
<blockquote> <p>(Note that the color needs to supplied as a separate resource here because the <code>android:windowBackground</code>attribute only supports a reference to another resource; unlike <code>android:colorBackground</code>, it can not be given a color literal.)</p></blockquote> <p>注意到<code>android:windowBackground</code>只支持对另一资源的引用,这与<code>android:colorBackground</code>不一样.</p>