android - How can I fill RecyclerView with GridLayoutManager from right to left -
i'm trying fill data recyclerview
gridlayoutmanager
:
gridlayoutmanager layoutmanager = new gridlayoutmanager(this, 3, gridlayoutmanager.vertical, false);
this fill data grid left right. first item put top-left place, etc.
but app i'm developing designed rtl language, need make fill right left.
i tried change last argument true
. scrolled recyclerview
way down.
also setting layoutdirection
attribute recyclerview
doesn't work (without considering min api 16 , attribute added api17+):
<android.support.v7.widget.recyclerview android:id="@+id/grid" android:layoutdirection="rtl" android:layout_width="match_parent" android:layout_height="match_parent"/>
how can create right left filled grid using recyclerview
?
create class extends gridlayoutmanager
,and override islayoutrtl()
method this:
public class rtlgridlayoutmanager extends gridlayoutmanager { public rtlgridlayoutmanager(context context, attributeset attrs, int defstyleattr, int defstyleres) { super(context, attrs, defstyleattr, defstyleres); } public rtlgridlayoutmanager(context context, int spancount) { super(context, spancount); } public rtlgridlayoutmanager(context context, int spancount, int orientation, boolean reverselayout) { super(context, spancount, orientation, reverselayout); } @override protected boolean islayoutrtl(){ return true; } }
Comments
Post a Comment