1

I have meet this problem when I try to upgrade my app to compile with compileSdkVersion 23

Just as my title says, the TextView used android:textColor="@android:color/white" no longer works.

I have tried to narrow down the cause by creating a simple testing app, and I have found that whenever my TextView has android:enabled="false", my android:textColor is being ignored.

I think I am going to file a issue to Android Developer Preview, however, I would like to confirm whether it is my own problem.

Here is the TextView I used for testing

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

Edit:

I have created a very simple project on github with this problem, I have tested it on emulator with android 19, 21, 22, 33, and on my Moto G with android 5.0

https://github.com/cyfung/BuggyTextView

Derek Fung
  • 8,171
  • 1
  • 25
  • 28
  • I've had similar problem when I've used support-libs 24.0.0-alpha1 by accident. On some TextViews, the textColor attribute did not work at all. – scana Mar 20 '16 at 22:51

2 Answers2

1

As a workaround, try to use selector with defined state for 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>
Derek Fung
  • 8,171
  • 1
  • 25
  • 28
Oleksandr
  • 6,226
  • 1
  • 46
  • 54
  • Thanks for your input, maybe there are some minor settings I am missing? I have put a sample project on github, actually it is just a default project with empty activity, and changing the colors only. Actually I have tested this on various emulators, android 19, 21, 22, 23, all having same problem. – Derek Fung Sep 04 '15 at 14:09
  • @DerekFung have you tried setting up selector instead of color? – Oleksandr Sep 04 '15 at 15:00
  • it works if using selector, suggested an edit, will upvote upon change – Derek Fung Sep 04 '15 at 15:12
0

Confirmed to be a bug, and fix would be available in future build.

https://mail.google.com/mail/u/0/#inbox/14fb020ef65f9a41

Please refer to answer from @Alexandr if you need a workaround.

Derek Fung
  • 8,171
  • 1
  • 25
  • 28