Элементы Gridlayout RecyclerView заполняют их родителей - PullRequest
0 голосов
/ 29 августа 2018

У меня есть рециклер, как показано ниже:

    <android.support.v7.widget.RecyclerView
    android:id="@+id/rv_months"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

и я установил для него менеджер сетки:

GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 3);

Я хочу разделить ширину recylerview между этими тремя элементами поровну.

Это мой товар родитель:

<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="match_parent"
android:layout_height="96dp">
....
 </android.support.v7.widget.CardView>

Как я могу поровну разделить родительский элемент recylcerview между этими элементами?

Я хочу, чтобы мой вид выглядел так, как показано ниже: 3 элемента имеют одинаковый размер, и они заполняют родительскую ширину

enter image description here

...