【发布时间】:2016-01-24 01:54:53
【问题描述】:
我在回收站视图中为每个项目使用卡片视图,但我在图片下方和上方得到空白,我不确定如何删除它。这是每个项目的 xml 布局。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cv_custom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:clickable="true"
android:elevation="2dp"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/image_path"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/event_image" />
<TextView
android:id="@+id/custom_event_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="marquee"
android:gravity="start|top"
android:maxLines="1"
android:padding="5dp"
android:textColor="@color/parent"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
这就是它当前所提供的 xml 的样子。一个项目 i 带有图像,一个没有。将回收器视图的背景设置为红色,以便更明显地看到间隙。
【问题讨论】:
标签: android padding android-recyclerview android-cardview