0

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?

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

It is not recommended to mix parent attribute and dot notation. Anyway, parent always overrides dot notation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.