【发布时间】:2011-10-06 14:15:41
【问题描述】:
我有一个列表视图,我想防止在选择时突出显示。背景颜色在列表视图行布局上设置为半透明。我做得越透明,它就越会以 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 listview highlight