Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何模仿样式化的ListView_Android_Xml_Android Listview - Fatal编程技术网

Android 如何模仿样式化的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:

到目前为止,我已经尝试使用属性来设置listview的背景,但我无法获得这种效果。如果有人能给我小费那就太好了


我知道我必须使用自定义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>