Android 具有不同颜色行示例的完整列表视图周围的圆角

Android rounded corner around full List view with different color rows example

您好,我正在尝试在具有不同列表视图行颜色的圆角中实现整个列表视图。

我能够为整个列表视图实现圆角。但是不同颜色的行无法适应圆角列表视图,特别是在列表视图的顶部和底部,因为它有圆角。

请帮忙解决这个问题

把你的 ListView 放在 RelativeLayout

里面
<RelativeLayout
        android:id="@+id/rel_Bg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/fragment_item_bg"
        android:padding="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp" >

        <ListView
            android:id="@+id/mListView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:divider="@null"
            android:dividerHeight="5dp"
            android:scrollingCache="true"
            android:smoothScrollbar="true" />
    </RelativeLayout>

fragment_item_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="#04A3C3" />

    <corners android:radius="10dip" />
</shape>

根据您的要求更改边距、填充和颜色

如果在此代码之后,您的问题没有解决,请发送您的 UI 代码。