2

I am using RecyclerView and GridLayoutManager to show item on Grid View, but I want to align this item to right means if there is an empty cell on a row, this empty cell should be on the left.

Thanks

GeniDeveloper
  • 361
  • 3
  • 18
  • 1
    Possible duplicate of [How can I fill RecyclerView with GridLayoutManager from right to left](https://stackoverflow.com/questions/32920867/how-can-i-fill-recyclerview-with-gridlayoutmanager-from-right-to-left) – Alireza Noorali Dec 15 '18 at 11:14

2 Answers2

0

Try using android:gravity="end".

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
  • 2
    Please, edit the answer, cause it looks more like a comment, which makes it a good candidate for deletion. – Onik Sep 25 '15 at 08:45
  • 2
    But I have enough reputation to `Recommend deletion` while reviewing low quality posts, which I did not, btw, for your answer, gently informing that the answer's in the queue :) – Onik Sep 25 '15 at 13:55
0

Try to use this Custom GridLayoutManager to fill items from right to left.

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.util.AttributeSet;

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;
    }
}
Alireza Noorali
  • 3,129
  • 2
  • 33
  • 80