-1

我想添加一种自定义样式,例如在一个主题中为紫色,在另一个主题中为红色。

<style name="subtitle_layout" parent="@android:style/Theme.Holo.Light">
    <item name="android:background">@color/purple</item>
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">40sp</item>
</style>

<style name="subtitle_layout2" parent="@android:style/Theme.Holo.Light">
    <item name="android:background">@color/black</item>
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">80sp</item>
</style>

<style name="Theme1" parent="android:Theme.Holo.Light">
    <item name="android:textColor">@color/black</item>
    <item name="@style/subtitle_layout">@style/subtitle_layout</item>
</style>
<style name="Theme2" parent="android:Theme.Holo.Light">
    <item name="android:textColor">@color/white</item>
    <item name="@style/subtitle_layout">@style/subtitle_layout2</item>
</style>

主题的变化有效,因为我看到了文本颜色的变化,但不是 android:textColor 我想放一个样式。但它不起作用。

4

1 回答 1

0

I guess you are trying to inherit existing styles to your theme, am I right? You can just set the style as your parent theme:

<style name="Theme1" parent="@style/subtitle_layout">
    <item name="android:textColor">@color/black</item>
</style>
于 2013-02-06T15:42:49.797 回答