Android ListFragment中的Listview边距和填充
我试图在列表片段中向列表视图添加填充和边距,但这是徒劳的,但它似乎忽略了所有参数,无论我将id放在何处。我如何处理它?我正在使用自定义适配器 这是我的右布局列表Android ListFragment中的Listview边距和填充,android,listview,android-listfragment,Android,Listview,Android Listfragment,我试图在列表片段中向列表视图添加填充和边距,但这是徒劳的,但它似乎忽略了所有参数,无论我将id放在何处。我如何处理它?我正在使用自定义适配器 这是我的右布局列表 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Description"
android:id="@+id/textView_desc"
android:paddingBottom="0dp"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Chapter information"
android:id="@+id/textView_chapter"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:textColor="#999"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time Stamp"
android:id="@+id/textView_offset"
android:textColor="#888"
android:visibility="invisible"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time Stamp"
android:id="@+id/textView_timestamp"
android:layout_centerVertical="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#888"/>
</RelativeLayout>
</LinearLayout>
在相对布局中,只需为根布局提供padding=10dp,您需要提供android:padding而不是android:margin
边距为外部视图定义了侧边上的额外空间(对于根视图,没有侧边)
填充它是视图与其内容之间的空间 是否使用自定义适配器如果是,则需要向膨胀的视图添加页边距是,我正在使用自定义适配器显示自定义适配器布局文件的xml代码自定义适配器中包含的唯一布局是每个项目的布局,同样,我包含了适配器代码我要求提供R.layout.list\u bookmarks视图的xml代码。