Btn.setenabled(false); Does Not Make The Button Text Grayed Out In Targetsdkversion 25
After updating Android Studio to 2.3 and gradle version 3.3, btn.setEnabled(false); Text color on the disabled button does not gray out. Functionality is working fine but I have
Solution 1:
Try this:
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><!-- disabled state --><itemandroid:state_enabled="false"android:color="#9D9FA2" /><itemandroid:color="#000"/></selector>
From: Stackoverflow
Solution 2:
if (btn.isEnabled() == true)
{
btn.setTextColor(int Color);
}
else
{
btn.setTextColor(int Color);
}
It will definitely work. You can define colors respectively.
Solution 3:
try this:
from java end:
button.setTextColor(getApplication().getResources().getColor(R.color.red));
orbutton.setTextColor(0xff0000); //SET YOUR COLOR orbutton.setTextColor(Color.parseColor("#ff0000"));
and in xml :
<Buttonandroid:id="@+id/mybtn"android:text="text textx "android:layout_width="fill_parent"android:layout_height="wrap_content"android:textStyle="bold"android:textColor="#ff0000" /> <-- SET TEXT COLOR HERE -->
Ref.: Link
Post a Comment for "Btn.setenabled(false); Does Not Make The Button Text Grayed Out In Targetsdkversion 25"