【发布时间】:2018-05-08 17:07:06
【问题描述】:
我在带有网格布局管理器的回收站视图中有一个卡片视图。我想删除卡片之间的空间,但也要保留卡片的特定宽度。
这是我的布局活动:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".Catalog"
android:id="@+id/content_mainfragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
这是我的名片:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="315dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="@color/primaryLightColor"
app:layout_constraintBottom_toTopOf="@+id/card_Title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
....
...
....
【问题讨论】:
-
您可以更改
CardView所在的根布局的填充,这将更改卡片之间的填充 -
没试过不行
-
需要看到比这更多的 XML...
-
更新了我的问题
-
您的卡片宽度设置为 android:layout_width="350dp".... 这就是原因。做那个 match_parent
标签: android android-layout gridview android-recyclerview