Skip to content

Commit

Permalink
fix issue #15
Browse files Browse the repository at this point in the history
  • Loading branch information
niorgai committed Mar 3, 2017
1 parent 82b6335 commit 35471fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Add the dependency
```groovy
dependencies {
compile ('com.github.niorgai:StatusBarCompat:2.1.2', {
compile ('com.github.niorgai:StatusBarCompat:2.1.3', {
exclude group: 'com.android.support'
})
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ext {
]

libs = [
supportVersion : "25.1.0"
supportVersion : "25.2.0"
]
}

13 changes: 8 additions & 5 deletions library/src/main/java/qiu/niorgai/StatusBarCompatKitKat.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ static void translucentStatusBar(Activity activity) {
*
* 1. set Window Flag : WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
* 2. set FitsSystemWindows for views.
* 3. removeFakeStatusBarViewIfExist
* 4. removeMarginTopOfContentChild
* 5. add OnOffsetChangedListener to change statusBarView's alpha
* 3. add Toolbar's height, let it layout from top, then add paddingTop to layout normal.
* 4. removeFakeStatusBarViewIfExist
* 5. removeMarginTopOfContentChild
* 6. add OnOffsetChangedListener to change statusBarView's alpha
*/
static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBarLayout appBarLayout, final CollapsingToolbarLayout collapsingToolbarLayout,
Toolbar toolbar, int statusColor) {
Expand All @@ -170,11 +171,13 @@ static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBa
collapsingToolbarLayout.setFitsSystemWindows(false);
collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(false);

toolbar.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(false);
if (toolbar.getTag() == null) {
CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
lp.height += getStatusBarHeight(activity);
int statusBarHeight = getStatusBarHeight(activity);
lp.height += statusBarHeight;
toolbar.setLayoutParams(lp);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
toolbar.setTag(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void translucentStatusBar(Activity activity, boolean hideStatusBarBackgro
* 1. change to full-screen mode(like translucentStatusBar).
* 2. cancel CollapsingToolbarLayout's WindowInsets, let it layout as normal(now setStatusBarScrimColor is useless).
* 3. set View's FitsSystemWindow to false.
* 4. adjust toolbar's height to layout.
* 4. add Toolbar's height, let it layout from top, then add paddingTop to layout normal.
* 5. change statusBarColor by AppBarLayout's offset.
* 6. add Listener to change statusBarColor
*/
Expand Down Expand Up @@ -125,11 +125,13 @@ public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets)
((View) appBarLayout.getParent()).setFitsSystemWindows(false);
appBarLayout.setFitsSystemWindows(false);

toolbar.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(false);
if (toolbar.getTag() == null) {
CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
lp.height += getStatusBarHeight(activity);
int statusBarHeight = getStatusBarHeight(activity);
lp.height += statusBarHeight;
toolbar.setLayoutParams(lp);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
toolbar.setTag(true);
}

Expand Down

0 comments on commit 35471fa

Please sign in to comment.