XML file saved at res/color/button_text.xml:

<?xml version="1.0" encoding="utf-8"?>
<selectorxmlns:android="http://schemas.android.com/apk/res/android">
   
<itemandroid:state_pressed="true"
         
android:color="#ffff0000"/><!-- pressed -->
   
<itemandroid:state_focused="true"
         
android:color="#ff0000ff"/><!-- focused -->
   
<itemandroid:color="#ff000000"/><!-- default -->
</selector>

This layout XML will apply the color list to a View:

<Button
   
android:layout_width="fill_parent"
   
android:layout_height="wrap_content"
   
android:text="@string/button_text"
   
android:textColor="@color/button_text"/>

相关文章:

  • 2022-01-09
  • 2021-06-21
  • 2021-10-19
  • 2022-12-23
  • 2021-06-12
  • 2021-12-17
  • 2022-12-23
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案