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
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
Try using android:gravity="end"
.
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;
}
}