ListView样式实现总结

ListView样式实现总结

1 设置listview 的Item之间的横线 颜色和高度
    android:divider="#8E8E8E"
    android:dividerHeight="1px"
2 设置 ListView在选择多项时,背景变黑
android:scrollingCache="false"
 
3 设置 ListView 选择Item的高亮
android:listSelector="@android:color/transparent"

4 设置Item 获得焦点样式,选中样式,未选择样式
  分三部分
  [1] 设置基础颜色 values/colors.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="transparent">#FFD306</color>
       <color name="silver">#00ffffff</color>
       <color name="darkgray">#808080FF</color>
    <color name="white">#FFFFFFFF</color>
<color name="red">#FE2E2E</color>
<color name="ltgray">#4B8A08</color>
   <color name="pressed">#fff22fff</color> 
   <color name="selected">#fff33fff</color> 
   <color name="focused">#ffff44ff</color>
</resources>


  [2] 设置 selector  xml文件 路径:drawable/catalog_list_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
 android:state_selected="false"
    android:state_pressed="false"
    android:drawable="@color/ltgray"/>
<item android:state_pressed="true"
    android:drawable="@color/red"/>
<item android:state_selected="true"
 android:state_pressed="false"
    android:drawable="@color/red"/>
</selector>
  [3]设置Item项的背景
android:background="@drawable/catalog_list_selector"

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