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>


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