Skip to content

Instantly share code, notes, and snippets.

@waqasakram117
Created February 23, 2017 12:34
Show Gist options
  • Select an option

  • Save waqasakram117/93773cea696ee1e11cbc591004872ba6 to your computer and use it in GitHub Desktop.

Select an option

Save waqasakram117/93773cea696ee1e11cbc591004872ba6 to your computer and use it in GitHub Desktop.
// A method to find height of the status bar this will useful with navigation drawer
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
// Retrieve the AppCompact Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Set the padding to match the Status Bar height
toolbar.setPadding(0, getStatusBarHeight(), 0, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment