Rounded corner of list item on Android?

跟風遠走 提交于 2019-12-09 23:57:59

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/4026426/rounded-corner-of-list-item-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!