2013-10-30 147 views
0

我正在嘗試從默認的橙色/黃色顏色更改ListView的突出顯示顏色。我嘗試過設置android:listSelector,但這會導致點擊的行被永久選中。我如何更改高亮顏色或防止行保持選定狀態?更改ListView突出顯示顏色

回答

0

您必須使用自定義列表視圖變革BG和BgHover 例如:

繪製對象文件夾:

gradient_bg.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 

    <!-- Gradient Bg for listrow --> 
    <gradient 
     android:angle="270" 
     android:centerColor="#fdfdfd" 
     android:endColor="#f8f8f8" 
     android:startColor="#fdfdfd" /> 

</shape> 

gradient_bg_hover.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 

    <!-- Gradient Bg for listrow --> 
    <gradient 
     android:angle="270" 
     android:centerColor="#fdfdfd" 
     android:endColor="#f8f8f8" 
     android:startColor="#f8f8f8" /> 

</shape> 

list_selector.xml

<!-- Selector style for listrow --> 
<item android:drawable="@drawable/gradient_bg" android:state_pressed="false" android:state_selected="false"/> 
<item android:drawable="@drawable/gradient_bg_hover" android:state_pressed="true"/> 
<item android:drawable="@drawable/gradient_bg_hover" android:state_pressed="false" android:state_selected="true"/> 

和現在使用這list_selector.xml到列表視圖

背景
相關問題