android如何在listview的每个边缘设置填充
我有以下列表视图。我想在listview周围设置空间,这样它就不会占据整个屏幕。我怎样才能做到这一点 我在listview和父相对布局上尝试了填充和边距的每一种组合,似乎都没有效果 事先谢谢你,马特android如何在listview的每个边缘设置填充,android,listview,Android,Listview,我有以下列表视图。我想在listview周围设置空间,这样它就不会占据整个屏幕。我怎样才能做到这一点 我在listview和父相对布局上尝试了填充和边距的每一种组合,似乎都没有效果 事先谢谢你,马特 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientati
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#8fff"
android:cacheColorHint="#0000"
android:divider="#700000ff"
android:dividerHeight="4px" >
</ListView>
</RelativeLayout>
.编辑1
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#8fff"
android:cacheColorHint="#0000"
android:divider="#700000ff"
android:dividerHeight="4px" >
</ListView>
</RelativeLayout>
</RelativeLayout>
将您的列表视图放在另一个布局中,并对该布局进行填充。android:layout\u margin=“sizeindp”
用这个它对我有用
你想实现这个目标吗 用这个
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#8fff"
android:cacheColorHint="#0000"
android:layout_margin="15dp"
android:padding="10dp"
android:divider="#700000ff"
android:dividerHeight="4px" >
</ListView>
那么您给listview添加了填充和边距了吗?您好,很抱歉,它不起作用,listview仍然占据了整个屏幕。我所做的更改在编辑1中。谢谢,我应该把边距代码放在哪里,我想我已经在你的Listview xml布局中尝试了这一点
,它没有什么区别,你想实现我发布的它的快照吗?如果是这样,那么我给出的代码是有效的不要为相对布局提供填充,而是为ListView提供边距。它将从ListView的所有四个侧面留出空间。