Android风格的继承不起作用



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>

当我使用这个

<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"/>

此按钮属性仅为"大",不绘制为"红色"。为什么

您的Red.LARGE样式需要使用父属性。如果更改为:,则Red.LARGE将继承红色

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

最新更新