我使用水平RecyclerView
,我的清单项目之间的保证金是恒定的,我想增加清单项目缺口,我尝试增加layout_margin
但没有变化。无法在水平RecycleView项目之间添加保证金
下面是我的列表项布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:background="@color/colorWhite"
app:cardElevation="2dp"
app:cardCornerRadius="5dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="0dp">
<ImageView
android:id="@+id/itemImage"
android:layout_width="170dp"
android:layout_height="170dp"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher_background" />
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/itemImage"
android:gravity="center"
android:padding="5dp"
android:text="Sample title"
android:textColor="@color/colorTextBlack"
android:textSize="16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="14dp"
android:gravity="center"
android:textSize="12dp"
android:textColor="#9f9f9f"
android:text="2 Aug, London" />
</LinearLayout>
</android.support.v7.widget.CardView>
有人可以帮助我的问题?
为'CardView'应用'padding_right'。你也可以使用ItemDecorator。 – Piyush
检查这个答案https://stackoverflow.com/a/44543420/7666442 –
@NileshRathod我试过这个答案,仍然为列表中的第一项边距未设置 –