首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

旋钮Listview等点击效果

2012-09-29 
按钮Listview等点击效果??xml version1.0 encodingutf-8 ?selector xmlns:androidhttp://schem

按钮Listview等点击效果
?旋钮Listview等点击效果旋钮Listview等点击效果

    <?xml version="1.0" encoding="utf-8" ?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:drawable="@drawable/没有焦点时图片背景" /> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/非触摸模式下获得焦点并单击时的背景图片" /> <!--双条件--> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/触摸模式下单击时的背景图片" /> <item android:state_selected="true" android:drawable="@drawable/选中时的图片背景" /> <item android:state_focused="true" android:drawable="@drawable/获得焦点时的图片背景" /> <item android:drawable="@drawable/silver" /> <!--default color 当对应状态下没有定义时使用此default --></selector>

    定义item时具体可以选择的条件有:
    ???旋钮Listview等点击效果旋钮Listview等点击效果
      android:state_pressed=["true" | "false"] //被点击 android:state_focused=["true" | "false"] //获得焦点 android:state_selected=["true" | "false"] //被选中 android:state_checkable=["true" | "false"] //可以被check时 android:state_checked=["true" | "false"] //被check时,例如用于checkbox android:state_enabled=["true" | "false"] //可用是,即能接收click/touch事件 android:state_window_focused=["true" | "false"] //所在的窗口获得焦点


      然后再listview的layout定义里加上就ok了

      ?旋钮Listview等点击效果旋钮Listview等点击效果
        android:background="@drawable/list_bg_selector"


        这种方式不仅能应用于listview,也可以用于设置其他控件,比如button,在选中、点击等不同状态下的显示方式

热点排行