Skip to content

Instantly share code, notes, and snippets.

@cliffgr
Last active March 5, 2018 15:01
Show Gist options
  • Save cliffgr/0fc058dfa6f24f5e378d09b678833f75 to your computer and use it in GitHub Desktop.
Save cliffgr/0fc058dfa6f24f5e378d09b678833f75 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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment