android - 如何更改默认禁用的 EditText 的样式?

标签 android styles android-edittext default

使用 EditText enabled="false"时看起来不太好。我怎样才能改变它 自动为所有控件?

我已添加此图片以供引用。 enter image description here

有人可以帮助我吗?谢谢。

最佳答案

在drawables中创建一个自定义选择器并将其设置为

<EditText android:textColor="@drawable/edit_text_selector" />

1) 在“colors.xml”中定义启用和禁用状态的颜色:

<color name="enabled_color">#F7FE2E</color>
<color name="disabled_color">#000000</color>

2) 在“drawable/edit_text_selector.xml”中:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="@color/disabled_color"/>
    <item android:color="@color/enabled_color"/>
</selector>

3) 在您的 layout.xml 中:

<EditText
    android:id="@+id/customEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:enabled="false"
    android:text="Hello!"
    android:textColor="@drawable/edit_text_selector" />

关于android - 如何更改默认禁用的 EditText 的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16337063/

相关文章:

android - 如何使用我的应用程序的付费版本作为免费版本的 "key"?

android - 如何从广播接收器引用应用程序上下文

android - 如何删除 Android EditText 光标指示器?

android - 检查文本更改edittext上的大写,小写,长度和符号

css - SASS/Compass 风格检查器

java - 自定义Edittext输入文本后隐藏pin栏

android - 如何创建 100% 自定义 DialogFragment

android - 使用 Intent 显示二维码时是否可以更改 ZXing 的背景?

javascript - 使用 JavaScript 或 jQuery 更改 CSS 规则

c# - 为什么我不能将 Orientation 属性添加到 WPF 中的 Style Setter