开发者

Rounded corner of list item on Android?

How to setup the attribute to achieve the rounded corner for each item in the ListView? Please kindly give an example if you can, thanks!

for example: http://www.flickr.com/photos/jaxxdotorg/3640222441/in/set-72157619952823330/

EDIT: That's my code here for the answer.

<?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>


You can achieve this with shapes.

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>

The corner element specifies the size of the rounded corner. Now all you need to do is specify this drawable as the background to each list element.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜