将选择器添加到listview项目

时间:2014-06-04 16:41:26

标签: android

我使用以下xml代码在列表项选择上显示光滑的顶部白色条带和底部白色条带。问题是它在列表项选择上显示渐变。我想,我在xml中遗漏了一些东西,请帮助我。

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

            <gradient
                android:startColor="@android:color/white"
                android:centerColor="@android:color/transparent"
                android:endColor="@android:color/white"
                android:angle="90" />
        </shape>
    </item>
</selector>

1 个答案:

答案 0 :(得分:0)

<!-- If you simply want a background for your list item, use the following -->

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

    <item>
        <shape android:shape="rectangle"><stroke android:color="@color/popup_border" android:width="1dp"/>  <!-- For border/outline(Remove this line if you don't want border/outline)-->
            <gradient android:startColor="@android:color/white" android:centerColor="@android:color/transparent" android:endColor="@android:color/white" android:angle="270" />
        </shape>
    </item>

</selector>