当我尝试升级我的应用以使用compileSdkVersion
进行编译时遇到了这个问题23
就像我的标题所述,使用android:textColor="@android:color/white"
的TextView不再起作用。
我试图通过创建一个简单的测试应用程序来缩小原因,并且发现只要我的TextView具有android:enabled="false"
,我的android:textColor
都会被忽略。
我想将要提交给Android Developer Preview的问题,但是,我想确认是否是我自己的问题。
这是我用于测试的TextView
<TextView
android:enabled="false"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textSize="50sp"
android:gravity="center"
android:layout_centerInParent="true"/>
编辑:
我在github上创建了一个非常简单的项目来解决此问题,我已经在带有Android 19、21、22、33的模拟器上以及在带有Android 5.0的Moto G上进行了测试
https://github.com/cyfung/BuggyTextView
最佳答案
解决方法是,尝试为Android:state_enabled =“ false”使用状态已定义的选择器。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/white" android:state_enabled="false"/>
<item android:color="@android:color/white"/>
</selector>
关于android - Android M开发人员预览-TextView android:textColor被忽略,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32394723/