Skip to content

Instantly share code, notes, and snippets.

@bapspatil
Created January 19, 2018 09:31
Show Gist options
  • Save bapspatil/3fdf42d8e578acb049147f63e58dce9a to your computer and use it in GitHub Desktop.
Save bapspatil/3fdf42d8e578acb049147f63e58dce9a to your computer and use it in GitHub Desktop.
private int numberOfColumns() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// You can change this divider to adjust the size of the poster
int widthDivider = 400;
int width = displayMetrics.widthPixels;
int nColumns = width / widthDivider;
return nColumns;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment