Skip to content

Commit

Permalink
fix bug in setColorDiff method
Browse files Browse the repository at this point in the history
  • Loading branch information
fingerart authored and jaeger committed Oct 20, 2016
1 parent c37acf2 commit ad9bf3d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions library/src/main/java/com/jaeger/library/StatusBarUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ public static void setColorDiff(Activity activity, @ColorInt int color) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 生成一个状态栏大小的矩形
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
int count = decorView.getChildCount();
if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
decorView.getChildAt(count - 1).setBackgroundColor(color);
transparentStatusBar(activity);
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
// 移除半透明矩形,以免叠加
if (contentView.getChildCount() > 1) {
contentView.getChildAt(1).setBackgroundColor(color);
} else {
StatusBarView statusView = createStatusBarView(activity, color);
decorView.addView(statusView);
contentView.addView(createStatusBarView(activity, color));
}
setRootView(activity);
}
Expand Down

0 comments on commit ad9bf3d

Please sign in to comment.