I have the following listview. I'd like to set space around the listview so it doesn't fill the whole screen. How can i achieve this.
I've tried every combination of padding and margins on the the listview and the parent relative layout, none seem to have an effect.
Thanks in advance Matt.
<?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>
.Edit 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>
将您的listview放在另一个布局中,并对该布局进行填充。
android:layout_margin="sizeindp"
use this it works for me do you want to achieve this !!!!
Use this..
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.