Skip to content

状态栏工具类,改变状态栏颜色,改变字体颜色

Notifications You must be signed in to change notification settings

wutong751/StatusBarUtil

 
 

Repository files navigation

StatusBarUtil

设置主题

注意: 要设置fitsSystemWindows为true

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:fitsSystemWindows">true</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

方法

 设置字体颜色为黑色
 setImmersiveStatusBar(Activity activity,boolean fontIconDark)
 设置状态栏透明
 setTranslucentStatus(Activity activity)
 设置状态栏的颜色
 setStatusBarColor(Activity activity, int colorId)

使用方式

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        StatusBarUtil.setImmersiveStatusBar(this,true);
    }
}

效果显示

详细解析

About

状态栏工具类,改变状态栏颜色,改变字体颜色

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%