创建带圆角的列表视图显示部分角

时间:2015-06-26 18:41:17

标签: android listview

我正在尝试创建一个带圆角的列表视图,但由于某种原因,并非所有角都会四舍五入。这就是它的样子

enter image description here

我使用以下代码

创建了背景
  <LinearLayout
        android:id="@+id/third_section"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/second_section"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/layout_bg"
        android:orientation="horizontal"
        android:weightSum="4">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1">

                <TextView
                    android:id="@+id/heading"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="10dp"
                    android:paddingTop="10dp"
                    android:layout_margin="10sp"
                    android:text="Contact us"
                    android:textColor="@color/app_grey_color"
                    android:textSize="17sp" />
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="0.3dp"
                android:padding="10sp"
                android:layout_margin="10sp"
                android:background="@android:color/darker_gray" />

            <ListView
                android:id="@+id/contact_us_list_view"
                android:layout_width="wrap_content"
                android:divider="@null"
                android:dividerHeight="0dp"
                android:layout_height="wrap_content"/>


        </LinearLayout>
    </LinearLayout>

我的布局文件中有以下内容

PHPMyAdmin

任何想法都将不胜感激!

2 个答案:

答案 0 :(得分:0)

尝试在LinearLayout中添加一些填充。看起来你的列表视图背景颜色只是背景重叠。

答案 1 :(得分:0)

我从您在问题中发布的图片中看到的内容。

你的ListView以某种方式覆盖你的边界。     尝试将填充添加到列表视图中。

<ListView
   android:id="@+id/contact_us_list_view"
   android:layout_width="wrap_content"
   android:divider="@null"
   android:dividerHeight="0dp"
   android:padding="10dp"              // OverHere
   android:layout_height="wrap_content"/>

我在你的布局中看到的其他内容是你使用的是“sp”而不是“dp” 在许多地方。