Reputation: 4717
<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.
Upvotes: 5
Views: 6936
Reputation: 2482
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
Upvotes: 0
Reputation: 10955
Just set text color to black will make it better:
android:textColor="@android:color/black"
Upvotes: 0
Reputation: 575
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>
Upvotes: 5
Reputation: 3355
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.
Upvotes: -2