A better way to color status bar and fix screen mess sometimes in Lollipop
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
auto:statusBarColor="@color/theme_primary_dark">
|
||||
auto:statusBarColor="@android:color/transparent">
|
||||
|
||||
<com.hippo.scene.StageLayout
|
||||
android:id="@+id/stage"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Content" parent="AppTheme.NoActionBar">
|
||||
<item name="android:windowBackground">@null</item>
|
||||
<item name="android:windowBackground">@color/theme_primary_dark</item>
|
||||
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme.Content" parent="AppTheme.NoActionBar">
|
||||
<item name="android:windowBackground">@null</item>
|
||||
<item name="android:windowBackground">@color/theme_primary_dark</item>
|
||||
|
||||
<item name="android:windowTranslucentStatus">false</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
|
||||
Reference in new issue
Block a user