Skip to content

Latest commit

 

History

History
118 lines (106 loc) · 3.71 KB

File metadata and controls

118 lines (106 loc) · 3.71 KB

StatusBarUtil

Status bar for Android 4.4-10.0 models with improved color, gradient and immersive experience

面向Android开发 GitHub stars GitHub forks GitHub issues GitHub license

中文

Sample

Download Apk

Phone model demo

Android-9.0 Android-4.4

Gradle

repositories {
    ...
    maven { url 'https://www.jitpack.io' }
}

dependencies {
    implementation 'com.github.Ye-Miao:StatusBarUtil:1.7.5'
}

Usage

Set the solid color status bar

in your layout XML

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/blue"/>

in your activity

StatusBarUtil.setColor(this, mColor);

Set the gradient status bar

in your layout XML

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/blue"/>

in your activity

StatusBarUtil.setGradientColor(this, mToolbar);

Set the transparent status bar

in your activity

StatusBarUtil.setTransparentForWindow(this);

Set the status bar bright mode(Applicable to Android6.0 and above)

in your activity

StatusBarUtil.setLightMode(this);

Set the status bar dark mode (for Android6.0 and above)

in your activity

StatusBarUtil.setDarkMode(this);

Increase the paddingTop of the View, the added value is the status bar height (specific use can be referenced in the demo)

You can set the toolbar height to expand to the status bar to implement a solid color status bar

in your layout XML

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/blue"/>

in your activity

StatusBarUtil.setPaddingTop(this, mToolbar);

You can set the toolbar height to expand the status bar to implement a gradient color status bar

in your layout XML

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/gradient_color"

in your activity

StatusBarUtil.setPaddingTop(this, mToolbar);

License

Copyright 2019 Ye-Miao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.