Last active
August 29, 2015 14:25
-
-
Save JohnMars/4de6ae4d95044b05843d to your computer and use it in GitHub Desktop.
Fixing bug that puts toolbar out of screen on API 21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void fixApi21ToolBarBug(Toolbar toolbar){ | |
| if(Build.VERSION.SDK_INT!=21) return; //only on api 21 | |
| final int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); | |
| final int result = (resourceId>0) ? getResources().getDimensionPixelSize(resourceId)*2 : 0; | |
| final CollapsingToolbarLayout.LayoutParams params = | |
| (CollapsingToolbarLayout.LayoutParams)toolbar.getLayoutParams(); | |
| params.topMargin -= result; | |
| toolbar.setLayoutParams(params); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment