Android 如何模仿样式化的ListView
我正在尝试创建一个圆形和白色的ListView: 到目前为止,我已经尝试使用属性来设置listview的背景,但我无法获得这种效果。如果有人能给我小费那就太好了Android 如何模仿样式化的ListView,android,xml,android-listview,Android,Xml,Android Listview,我正在尝试创建一个圆形和白色的ListView: 到目前为止,我已经尝试使用属性来设置listview的背景,但我无法获得这种效果。如果有人能给我小费那就太好了 我知道我必须使用自定义listview,因此我相信我必须用XML为自定义列表项重新创建它。您可以通过添加以下代码来创建它: 在可绘制文件夹中创建圆角.xml,如下所示: <ListView android:id="@+id/listview" android:layout_width="fill_
我知道我必须使用自定义listview,因此我相信我必须用XML为自定义列表项重新创建它。您可以通过添加以下代码来创建它: 在可绘制文件夹中创建圆角.xml,如下所示:
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@drawable/rounded_corners"
>
</ListView>
圆角.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上添加如下内容:
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@drawable/rounded_corners"
>
</ListView>