【发布时间】:2017-01-18 11:26:52
【问题描述】:
当我禁用我的微调器时,它会显示带有 alpha 的文本,因此 texte 变得有点不可见,我的问题是如何更改此颜色? PS:我不需要更改微调器文本的颜色。
【问题讨论】:
-
不重复,我需要更改微调器禁用状态的颜色而不是启用状态的颜色
-
所以你想像残疾人一样显示它还是不显示为残疾人?
-
不显示为残疾人。
当我禁用我的微调器时,它会显示带有 alpha 的文本,因此 texte 变得有点不可见,我的问题是如何更改此颜色? PS:我不需要更改微调器文本的颜色。
【问题讨论】:
在res中创建颜色文件夹,并创建颜色状态my_text_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/disableColor" android:state_enabled="false"/>
<item android:color="@color/enableColor"/>
</selector>
和你的文本视图 看起来像
<TextView
android:textColor="@color/my_text_color"
在适配器中,您需要扩展包含 Textview 的布局。 在您的适配器构造函数中,也发送 textview 的 id
public CustomAdapter(Activity context,int resouceId, int textviewId, List<RowItem> list){
super(context,resouceId,textviewId, list);
flater = context.getLayoutInflater();
}
调用它
CustomAdapter adapter = new CustomAdapter(MainActivity.this,
R.layout.listitems_layout, R.id.title, rowItems);
【讨论】:
<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: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" />
//drawable/edit_text_selector.xml中使用的第一个代码
【讨论】: