When i can just use the following code to adjust the width of the columns(240 is the default width of each column while on portrait mode):
`mPhotoRecyclerView.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
int desiredColumnNumber = mPhotoRecyclerView.getMeasuredWidth() / 240;
if ((mPhotoRecyclerView.getMeasuredWidth() % 240) > 0.5) {
desiredColumnNumber ++;
}
gridLayoutManager.setSpanCount(desiredColumnNumber );
return true;
}
});`