button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR
或者
button.setTextColor(0xff0000); //SET CUSTOM COLOR
或者
button.setTextColor(Color.parseColor("#ff0000"));
在 xml 中:
<Button android: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 -->
尝试这个:
或者
或者
在 xml 中: