kibar
kibar

Reputation: 824

Android style inheritance not working

styles.xml

    <style name="Red" parent="android:TextAppearance.DeviceDefault.Medium.Inverse">
        <item name="android:textColor">#f00</item>
    </style>

    <style name="Red.LARGE">
        <item name="android:textSize">30sp</item>
    </style>

When i use this;

<Button
    android:id="@+id/save"
    android:text="@string/save"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/save_marginTop"
    android:gravity="center"
    style="@style/Red.LARGE"/>

This button attribute only Large and doest painting to Red. Why?

Upvotes: 0

Views: 873

Answers (1)

browndwarf75
browndwarf75

Reputation: 94

Your Red.LARGE style needs to use the parent attribute. Red.LARGE will inherit Red if it is changed to:

<style name="Red.LARGE" parent="Red">
    <item name="android:textSize">30sp</item>
</style>

Upvotes: 1

Related Questions