如何实现Android沉浸式状态栏

2024-12-03 17:40:03
推荐回答(1个)
回答1:

实现Android沉浸式状态栏很简单,加一个android:fitsSystemWindows="true",public static void setSystemBar(Activity activity, int color) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

setTranslucentStatus(activity, true);
SystemBarTintManager tintManager = new SystemBarTintManager(activity);

tintManager.setStatusBarTintEnabled(true);

// 使用颜色资源
tintManager.setStatusBarTintResource(color);

}