Android上列表项的圆角?

时间:2010-10-26 17:50:52

标签: android listview rounded-corners

如何设置属性以实现ListView中每个项目的圆角? 如果可以的话,请举个例子,谢谢!

例如: http://www.flickr.com/photos/jaxxdotorg/3640222441/in/set-72157619952823330/

编辑: 这是我的答案代码。

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
    android:startColor="#ffff"
    android:endColor="#fddd"
    android:angle="270" />
<corners
    android:radius="13dp" />
<stroke
    android:width="1dp"
    android:color="#feee" />
</shape>

1 个答案:

答案 0 :(得分:7)

你可以通过形状实现这一目标。

Checkout the Shape Drawable documentation

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:radius="12dp"/>
    <stroke
        android:width="1dp"
        android:color="@color/blue" />
</shape>

角元素指定圆角的大小。现在您需要做的就是将此drawable指定为每个列表元素的背景。