Android ListView元素間隙線自定義漸變效果

 首先創建一個簡單的ListView,並設置對應的屬性

<ListView
     android:id="@+id/artistsNameView"
     android:layout_width="fill_parent"
     android:layout_height="match_parent" 
     android:divider="@drawable/jblineshape"
     android:dividerHeight="1sp">
 </ListView>


 

注意其中兩句:對應的就是設置ListView中的Item之間的間隙線的,使用的一個XML文件:jblineshape.xml(實現的是漸變線的效果)  

2    

3 --->> android:divider="@drawable/jblineshape"  

4 --->> android:dividerHeight="1sp" 


配置文件:jblineshape.xml,爲漸變效果的,透明->白色->透明(可根據自己需要進行設置)

 

配置文件:jblineshape.xml,爲漸變效果的,透明->白色->透明(可根據自己需要進行設置)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <gradient 
        android:startColor="#00000000"
        android:centerColor="#FFFFFF"
        android:endColor="#00000000"
    	/>
    <corners 
        android:radius="4dp"
        />

</shape>


 

效果圖:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章