我有一個列表視圖,我想要防止突出顯示選擇。背景顏色在列表視圖行佈局上設置爲半透明。透明度越高,它在Android的默認橙色中突出顯示的越多。防止在列表視圖中突出顯示
這裏的佈局:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/CodeFont"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:paddingLeft="20dip"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:cacheColorHint="#00000000"
android:background="#AAEBD5A8"
/>
如果我刪除的背景和設定這樣的顏色,
private void makeListDefault(ListView listView) {
int childCount = listView.getChildCount();
int i = 0;
for (i = 0; i < childCount; i++) {
View view = listView.getChildAt(i);
view.setBackgroundResource(R.drawable.hilight_no_gradient_correct_drawable);
}
}
這是不以任何方式影響的顏色。 hilight_no_gradient_correct_drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FF98FB98" android:endColor="#FF98FB98"
android:angle="90" />
<!-- 98FB98 is a shade of green -->
</shape>
任何想法?我也試過用選擇器,但似乎沒有影響顏色。
謝謝,我試過了,包括與選擇器作爲android:listSelector =「@ background/backgroundlistcell」從ListActivity佈局和列表項目佈局,但它似乎使項目完全透明,無論透明度和我用過的顏色。這可能會影響到我的代碼中的某些內容,因爲我正在從中突出顯示等等。但是,我無法得到這個工作。 –