btn.setEnabled(false);不会使 targetSdkVersion 25 中的按钮文本变灰 [英] btn.setEnabled(false); does not make the button text grayed out in targetSdkVersion 25

查看:30
本文介绍了btn.setEnabled(false);不会使 targetSdkVersion 25 中的按钮文本变灰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新Android Studio 2.3和gradle 3.3后,

After updating Android Studio to 2.3 and gradle version 3.3,

btn.setEnabled(false);

btn.setEnabled(false);

禁用按钮上的文本颜色不会变灰.功能工作正常,但我对文本颜色有问题,这可能会被用户误解.btn.setTextColor() 是一个选项,但它可能很乏味.任何其他替代方案都会有所帮助..

Text color on the disabled button does not gray out. Functionality is working fine but I have an issue with the text color which can be misunderstood by users. btn.setTextColor() is an option but then it can be tedious. Any other alternatives would be helpful..

推荐答案

试试这个:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- disabled state -->
  <item android:state_enabled="false" android:color="#9D9FA2" /> 
  <item android:color="#000"/>
</selector>

来自:Stackoverflow

这篇关于btn.setEnabled(false);不会使 targetSdkVersion 25 中的按钮文本变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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