0

I have recyclerview like below:

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

and I set a grid layout manager for it:

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

I want to divide recylerview width between these 3 items equally.

This is my item parent:

<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>

How can I divide recylcerview parent between these items equally?

I want my view look like below: 3 items have equall size and they fill their parent width

enter image description here

salmanseifian
  • 1,082
  • 3
  • 9
  • 26

0 Answers0