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

时间:2016-04-13 15:52:02

标签: android colors themes compatibility android-appcompat

我正在使用AppCompat在Android上面对这种奇怪的行为。

我的主题如下:

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

在我的布局中,我有这个按钮:

angular.module('AbcModule')
       .directive('abcDirective', ['MODULE_ROOT_URL', function (MODULE_ROOT_URL) {
           return {
               restrict: 'E',
               templateUrl:  MODULE_ROOT_URL + 'abc/abc.tpl.html'
           }

       }]);

在Android 6上进行编译效果非常好。但是,在Android 5上,按钮的文本颜色为黑色,无法使用xml textColor进行更改。它的工作原理是直接在代码中使用setTextColor。

我错过了什么?为什么appcompat主题会根据sdk版本而有所不同?此问题也会影响我的全部灰色文本视图。

1 个答案:

答案 0 :(得分:0)

我对不同的TextView s有同样的错误,突然变黑了。

我通过将所有support-v7库降级为最新稳定版来解决此问题,此时此刻为23.3.0,http://developer.android.com/intl/es/tools/support-library/features.html#v7-appcompat