Android style 的继承

对于Android的 style 的 XML文件同样也可以继承

比如下面的 CodeFont 的style样式:

<?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>

如果我们想继承 覆写 CodeFont某些属性  可以是 配置一个 CodeFont.xxx

例如:覆写字体颜色

  <stylename="CodeFont.Red">

<item name="android:textColor">#FF0000</item>

</style>

扩展属性,例如字体大小

<stylename="CodeFont.Red.Big">
<item name="android:textSize">30sp</item>
</style>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章