Selector常用状态:

      Android:state_selected 控件选中状态,可以为true或false

      android:state_focused 控件获得焦点状态,可以为true或false

      android:state_pressed 控件点击状态,可以为true或false

      android:state_enabled 控件使能状态,可以为true或false

      android:state_checkable 控件可勾选状态,可以为true或false

      android:state_checked 控件勾选状态,可以为true或false

 

设置不同状态下颜色:

      btn_enabled.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:andro>   

<!-- 默认 -->
    <item android:state_enabled="true">
        <color android:color="#e25050" />
        </item>
 <item android:state_enabled="false">
        <color android:color="#908e8e" />
        </item>
</selector>

设置不同状态下图片:

    btn_pressed.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:andro>
    <item android:state_pressed="true" android:drawable="@drawable/btn_arrow_left_pressed" />
    <item android:state_window_focused="true" android:state_focused="true" android:drawable="@drawable/btn_arrow_left_pressed" />
    <item android:state_window_focused="false" android:state_focused="false" android:drawable="@drawable/btn_arrow_left_normal" />
</selector>

相关文章:

  • 2022-12-23
  • 2021-09-04
  • 2021-12-28
  • 2021-04-26
  • 2022-12-23
  • 2021-11-19
  • 2021-12-28
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-11-19
  • 2021-07-14
  • 2022-12-23
相关资源
相似解决方案