Search code examples
androidstylesandroid-edittextdefault

How to change the default disabled EditText's style?


It isn't looking nice when using EditText enabled="false". How can I change it automatically for all of the controls?

I've added this image for reference. enter image description here

Can someone help me? Thanks.


Solution

  • In the color file define your color:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_enabled="false" android:color="@color/disabled_color" />
        <item android:color="@color/normal_color"/>
    </selector>
    

    In the layout:

    <EditText
        android:text="whatever text you want"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@drawable/example" />
    </EditText>