5
<EditText
    android:id="@+id/myEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:enabled="false" >
</EditText>

I have the above edit text which is disabled. I only take values from somewhere else and insert it there, the user can not type inside of it. However, the color of the edit text when in disabled form is too gray and not visible to the user sometimes. I prefer it to appear black. Is there any basic functionality I am not aware than can change the color of edit text when in disabled mode ? Any other work around works fine too.

tony9099
  • 4,567
  • 9
  • 44
  • 73
  • Possible duplicate of [Android: textColor of disabled button in selector not showing?](http://stackoverflow.com/questions/11225166/android-textcolor-of-disabled-button-in-selector-not-showing) – Sergei Bubenshchikov Jan 17 '17 at 05:21

4 Answers4

5

Your layout:

<EditText
    android:id="@+id/myEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:enabled="false"
    android:background = "@drawable/edittextdrawable.xml">
</EditText>

edittextdrawable.xml:

 <selector xmlns:android="http://schemas.android.com/apk/res/android">
            <item android:state_enabled="false"
                android:drawable="@drawable/PUT DRAWABLE HERE" />
            <item android:state_enabled="true"
                android:drawable="@drawable/PUT DRAWABLE HERE" />
 </selector>
Aboca
  • 575
  • 2
  • 9
0

Try to use statelist xml drawable, and set this to your EditText's background:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/bankszamlak_pressed" android:state_pressed="true" />  <!-- pressed -->
    <item android:drawable="@drawable/bankszamlak" android:state_focused="true" />  <!-- focused -->
    <item android:drawable="@drawable/bankszamlak" />  <!-- default -->
</selector> 

for further information check this link

Ibrahim Disouki
  • 2,642
  • 4
  • 21
  • 52
abbath
  • 2,444
  • 4
  • 28
  • 40
0

Just set text color to black will make it better:

android:textColor="@android:color/black" 
herbertD
  • 10,657
  • 13
  • 50
  • 77
-2

You should use TextView if you don't want the user to type into. Then you don't need to use disable to stop user from typing into it.

Owen Zhao
  • 3,205
  • 1
  • 26
  • 43
  • thanks for the tip. I was aware of this, however, I'm checking if what I asked is possible using EditTexts.. – tony9099 Aug 27 '13 at 13:29