【发布时间】:2016-09-11 07:20:40
【问题描述】:
问题是 - 当我在样式中定义文本颜色时:
<style name="Widget.App.SearcherButton" parent="Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
<item name="android:textColor">@color/buttontextcolor</item>
</style>
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="@dimen/searcherButtonHeight"
android:background="@drawable/button"
android:theme="@style/Widget.App.SearcherButton"
android:textOn="@string/favButtonText"
android:textOff="@string/favButtonText" />
它不起作用 - 这意味着ToggleButton 将具有默认文本颜色(黑色)。
但是,如果我直接在 ToggleButton 上设置 textColor 属性:
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="@dimen/searcherButtonHeight"
android:background="@drawable/button"
android:textColor="@color/buttontextcolor"
android:theme="@style/Widget.App.SearcherButton"
android:textOn="@string/favButtonText"
android:textOff="@string/favButtonText" />
然后就可以了。为什么会这样以及如何在样式中声明时使其工作?
【问题讨论】:
标签: android