A better way to color status bar and fix screen mess sometimes in Lollipop

This commit is contained in:
seven332 committed 2015-04-28 20:39:00 +08:00
1 parent 4b88ab5d92
commit 75d830d137
4 files changed
+9 -5

No files matched your search

@@ -54,12 +54,15 @@ public class StatusBarLayout extends ViewGroup {
private void init(Context context, AttributeSet attrs) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setWillNotDraw(false);
mPaint = new Paint();
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StatusBarLayout);
mPaint.setColor(a.getColor(R.styleable.StatusBarLayout_statusBarColor, Color.BLACK));
int color = a.getColor(R.styleable.StatusBarLayout_statusBarColor, Color.BLACK);
mPaint.setColor(color);
setWillNotDraw(Color.alpha(color) == 0);
a.recycle();
} else {
setWillNotDraw(false);
}
}
}
@@ -69,6 +72,7 @@ public class StatusBarLayout extends ViewGroup {
if (mStatusBarColor != color) {
mStatusBarColor = color;
mPaint.setColor(color);
setWillNotDraw(Color.alpha(color) == 0);
invalidate();
}
}