如何更改默认禁用的EditText样式? [英] How to change the default disabled EditText's style?

查看:184
本文介绍了如何更改默认禁用的EditText样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用EditText enabled ="false"时效果不佳.我该如何更改 自动对所有控件进行操作?

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.

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

Can someone help me? Thanks.

推荐答案

在颜色文件中定义您的颜色:

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>

在布局中:

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

这篇关于如何更改默认禁用的EditText样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆