0
我试图创建一个圆形的白色十岁上下的一个ListView:如何模仿程式化的ListView
到目前为止,我已经尝试使用< /风格>属性设置列表视图的背景,但我无法得到这种效果。如果有人能给我提示,这将是非常棒的。
我知道我必须使用自定义列表视图,因此我相信我必须在XML中为自定义列表项重新创建此列表项。
我试图创建一个圆形的白色十岁上下的一个ListView:如何模仿程式化的ListView
到目前为止,我已经尝试使用< /风格>属性设置列表视图的背景,但我无法得到这种效果。如果有人能给我提示,这将是非常棒的。
我知道我必须使用自定义列表视图,因此我相信我必须在XML中为自定义列表项重新创建此列表项。
您可以通过添加以下代码创建此:
绘制创建文件夹内rounded_corners.xml这样的:
rounded_corners.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="color of your choice" android:endColor="color of your choice"
android:angle="270"/>
<corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
</shape>
,并添加此列表视图上像这样:
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@drawable/rounded_corners"
>
</ListView>