GridLayoutManager code example
Example 1: android gridlayoutmanager
in res/values/dimens.xml:
<integer name="grid_columns">1</integer>
in res/values-w600dp/dimens.xml:
<integer name="grid_columns">2</integer>
in java:
int gridColumns = getResources().getInteger(R.integer.grid_columns);
Example 2: how to set recycler adapter in gridview
recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));