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

我有上面禁用的编辑文本。我只从其他地方获取值并将其插入那里,用户无法在其中输入。但是,在禁用形式下,编辑文本的颜色太灰,有时对用户不可见。我更喜欢它看起来是黑色的。是否有任何我不知道的基本功能可以在禁用模式下更改编辑文本的颜色?
任何其他解决方法也可以正常工作。

最佳答案

您的布局:

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

关于android - 禁用editText但颜色不同,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18466820/

10-12 00:13
查看更多