-1

I am using a recyclerView in my app with this code:

   mLayoutManagerMonth = new StaggeredGridLayoutManager(7, StaggeredGridLayoutManager.VERTICAL);
    monthRecycle.setLayoutManager(mLayoutManagerMonth);
    RecyclerView.Adapter mMonthAdapter = new MonthAdapter(populateMonthData(persianYear , persianMonth , persianDay) , MonthActivity.this);
    monthRecycle.setAdapter(mMonthAdapter);

and this is my xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layoutDirection="rtl">

    <include layout="@layout/month_layout"/>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigationView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:textAlignment="gravity"
        android:layout_gravity="right"
        android:background="#E0E0E0">


        <android.support.v7.widget.RecyclerView
            android:id="@+id/menuList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="100dp"
            android:layout_marginTop="25dp"
            android:layout_marginRight="25dp"
            android:layout_marginLeft="25dp"
            android:textDirection="rtl"/>

    </android.support.design.widget.NavigationView>




</android.support.v4.widget.DrawerLayout>

and this is my month_layout xml file:

 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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"
    xmlns:fab="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/month"
    android:orientation="vertical"
    android:layoutDirection="rtl"
    tools:layout_editor_absoluteY="25dp"
    tools:layout_editor_absoluteX="0dp">


    <android.support.v7.widget.Toolbar
        android:id="@+id/toolBar"
        android:layout_width="0dp"
        android:layout_height="56dp"
        android:layout_marginRight="0dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="0dp"
        app:layout_constraintHorizontal_bias="0.0">
    </android.support.v7.widget.Toolbar>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/monthLayout_recycle_month"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginTop="0dp"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolBar"
        app:layout_constraintVertical_bias="1.0"
        android:layoutDirection="rtl"
        app:layout_constraintBottom_toTopOf="@+id/btnAdd"/>

    <com.getbase.floatingactionbutton.FloatingActionButton
        android:id="@+id/btnAdd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="0dp"
        app:fab_colorNormal="#e53935"
        app:fab_icon="@drawable/ic_add"/>

</android.support.constraint.ConstraintLayout>

my problem is that I want to my recycled view items start from the right side of the screen and I set below code but id doesn't work!

android:layoutDirection="rtl"

Thank you for your help

Ehsan
  • 2,676
  • 6
  • 29
  • 56

1 Answers1

0
mLayoutManagerMonth.setReverseLayout(true);

This should do the trick. Put it after this line.

 mLayoutManagerMonth = new StaggeredGridLayoutManager(7, StaggeredGridLayoutManager.VERTICAL);
sHOLE
  • 343
  • 4
  • 15
  • Try this. http://stackoverflow.com/questions/32920867/how-can-i-fill-recyclerview-with-gridlayoutmanager-from-right-to-left – sHOLE May 06 '17 at 11:03