无法使用appcompat在Android上更改TextView的颜色

3

我在使用AppCompat时遇到了奇怪的问题。

我的主题如下:

<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/white</item>
    <item name="colorPrimaryDark">@color/gray_dark</item>
    <item name="colorAccent">@color/green</item>
    <item name="actionMenuTextColor">@color/gray_dark</item>
</style>

<style name="MyTheme.GreenButton" parent="Widget.AppCompat.Button">
    <item name="android:background">@drawable/green_button</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">18sp</item>
</style>

在我的布局中,我有这个按钮:
<Button
 android:id="@+id/login_button_login"
 style="@style/MyTheme.GreenButton"
 android:layout_width="120dp"
 android:layout_height="wrap_content"
 android:layout_margin="10dp"
 android:text="Log in"/>

在Android 6上编译非常完美。但是,在Android 5上,按钮的文本颜色为黑色,无法使用xml textColor更改。但是,直接在代码中使用setTextColor可行。

我错过了什么?为什么appcompat主题会根据sdk版本而不同?这个问题也影响到我的所有灰色textviews。

1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接