如何在列表视图的填充后面显示列表项?

时间:2014-11-05 06:24:45

标签: android android-layout listview android-listview

我用25dp填充创建了一个listview

<ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@null"
        android:dividerHeight="25dp"
        android:padding="20dp"
        android:scrollbars="none"></ListView>

这是listview的外观

enter image description here

当我向下滚动列表时,填充将覆盖列表项

enter image description here

我可以在列表视图的边框内创建列表视图可见范围,而不是在listview的填充内吗?


列出项目xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
                android:background="#fff">


    <ImageView
            android:id="@+id/button_history_list_item_one_function"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_centerVertical="true"
            android:layout_margin="20dp"
        android:src="@drawable/ic_launcher"/>


    <LinearLayout android:layout_width="100dp"
                  android:layout_height="match_parent"
                  android:orientation="vertical"
                    android:layout_alignParentRight="true"
        android:background="@drawable/left_border"
        android:padding="10dp"
                  >

    </LinearLayout>

</RelativeLayout>

此图像显示了我想要的内容

enter image description here

1 个答案:

答案 0 :(得分:0)

使用保证金代替填充

<ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@null"
        android:layout_margin="20dp"
        android:scrollbars="none"></ListView>

备用方式 - 如果填充对您很重要,请在列表视图中使用填充左右间距,并使用上边距和下边距。底部。

<ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@null"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:scrollbars="none"></ListView>
相关问题