【问题标题】:Change color of a disabled spinner Android更改禁用的微调器 Android 的颜色
【发布时间】:2017-01-18 11:26:52
【问题描述】:

当我禁用我的微调器时,它会显示带有 alpha 的文本,因此 texte 变得有点不可见,我的问题是如何更改此颜色? PS:我不需要更改微调器文本的颜色。

【问题讨论】:

  • 不重复,我需要更改微调器禁用状态的颜色而不是启用状态的颜色
  • 所以你想像残疾人一样显示它还是不显示为残疾人?
  • 不显示为残疾人。

标签: android styles spinner


【解决方案1】:

在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);

【讨论】:

    【解决方案2】:
    <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中使用的第一个代码

    【讨论】:

    • 感谢重播,但这不是我想要的。
    • @Euphor08 那么,你到底在看什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-15
    • 2016-09-06
    • 1970-01-01
    相关资源
    最近更新 更多