Удалите отступы между карточками в менеджере макета сетки вида переработчика - PullRequest
0 голосов
/ 08 мая 2018

У меня есть вид карты в виде переработчика с менеджером компоновки сетки. Я хочу убрать расстояние между карточками, но также сохранить определенную ширину карточек.

Вот мой макет активности:

<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" />
  ....
    ...
    ....

enter image description here

1 Ответ

0 голосов
/ 09 мая 2018

Вы можете установить ширину и высоту карты в соответствии с вашими требованиями. Смотрите код ниже, чтобы узнать больше.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_raw_visit_comments_receiver"
        android:layout_width="@dimen/scale_100dp"
        android:layout_height="@dimen/scale_100dp"
        android:layout_margin="5dp"
        card_view:cardCornerRadius="3dp"
        card_view:cardElevation="3dp">

        <RelativeLayout
            android:id="@+id/layout_raw_relative"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="4dp"
            android:gravity="center">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center">

                <ImageView
                    android:id="@+id/text_raw_company_grid_menu"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"/>

                <TextView
                    android:id="@+id/text_raw_company_profile_menu"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_below="@+id/text_raw_company_grid_menu"
                    android:textColor="@color/grid_menu_text_color"
                    android:textSize="@dimen/txt_11"
                    tools:text="Task"/>
            </RelativeLayout>
        </RelativeLayout>
    </android.support.v7.widget.CardView>
</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...