Skip to content

Instantly share code, notes, and snippets.

@cliffgr
Created March 5, 2018 15:01
Show Gist options
  • Save cliffgr/b384718d0824e0c69ad1535a97b6196f to your computer and use it in GitHub Desktop.
Save cliffgr/b384718d0824e0c69ad1535a97b6196f to your computer and use it in GitHub Desktop.
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
if (screenInches >= 6.5) {
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 4));
mRecyclerView.addItemDecoration(new ItemOffsetFullDecoration(this, R.dimen.item_offset));
} else {
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
mRecyclerView.addItemDecoration(new ItemOffsetDecoration(this, R.dimen.item_offset));
}
} else {
if (screenInches >= 6.5) {
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3, LinearLayoutManager.HORIZONTAL, false));
} else
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2, LinearLayoutManager.HORIZONTAL, false));
mRecyclerView.addItemDecoration(new ItemOffsetFullDecoration(this, R.dimen.item_offset));
}
@alexstyl
Copy link

alexstyl commented Mar 5, 2018

getResources().getInteger(R.inter.number_of_colums) 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment