改写ListView样式

ava代码 复制代码

  1. <ListView   
  2.          android:id= "@id/android:list"   
  3.          android:layout_width= "fill_parent"   
  4.          android:layout_height= "fill_parent"   
  5.          android:drawSelectorOnTop= "true"   
  6.          android:listSelector= "@drawable/selector"   
  7.          android:divider= "@drawable/list_line" />  
<ListView 
  android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:drawSelectorOnTop="true"
        android:listSelector="@drawable/selector"
        android:divider="@drawable/list_line"/>

selector:如下

Xml代码 复制代码
  1. selector xmlns:android = "http://schemas.android.com/apk/res/android" >   
  2.   
  3. < item   
  4. android:drawable = "@drawable/list_normal"   
  5. android:state_selected = "false"   
  6. android:state_pressed = "false" />   
  7.   
  8. < item   
  9. android:drawable = "@drawable/list_pressed"   
  10. android:state_selected = "false"   
  11. android:state_pressed = "true" />   
  12.   
  13. < item   
  14. android:drawable = "@drawable/list_pressed"   
  15. android:state_selected = "true" />   
  16.   
  17. </ selector >    
selector xmlns:android="http://schemas.android.com/apk/res/android"> 

<item 
android:drawable="@drawable/list_normal" 
android:state_selected="false" 
android:state_pressed="false" /> 

<item 
android:drawable="@drawable/list_pressed" 
android:state_selected="false" 
android:state_pressed="true" /> 

<item 
android:drawable="@drawable/list_pressed" 
android:state_selected="true" /> 

</selector>

android:divider="@drawable/list_line" 就是每项之间的横线

可以找个横线图片

/************************************************************************/

你可能感兴趣的:(android,xml)