ρяσ*_*я K 68
试试这个:
button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR
Run Code Online (Sandbox Code Playgroud)
要么
button.setTextColor(0xff0000); //SET CUSTOM COLOR
Run Code Online (Sandbox Code Playgroud)
要么
button.setTextColor(Color.parseColor("#ff0000"));
Run Code Online (Sandbox Code Playgroud)
并在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 -->
Run Code Online (Sandbox Code Playgroud)
使用该android:textColor属性.
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World"
android:textColor="@android:color/white" />
Run Code Online (Sandbox Code Playgroud)
button.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.red));
Run Code Online (Sandbox Code Playgroud)
这也是工作
| 归档时间: |
|
| 查看次数: |
71629 次 |
| 最近记录: |