自动化零件商城(www.rssme.com)专业PLC,变频器,直线模组,触摸屏,控制器,传感器等自动化商品网上购物商城,为广大中小工业企业提供优质、低价格和种类齐全的自动化零件。
文章目录

前言

简单记录一下Android中app如何设置状态栏的影藏或显示。

代码片段,只是流水文而已,请略过。

正文

java

public void updateStatusBar(Activity activity, boolean visible) {
    WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes();
    if (visible) {
        layoutParams.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        layoutParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    }
    activity.getWindow().setAttributes(layoutParams);
    activity.getWindow().getDecorView().setSystemUiVisibility(layoutParams.systemUiVisibility);
}

kotlin

fun updateStatusBar(activity: Activity, visible: Boolean) {
    val layoutParams = activity.window.attributes
    if (visible) {
        layoutParams.flags =
            layoutParams.flags and (WindowManager.LayoutParams.FLAG_FULLSCREEN.inv())
    } else {
        layoutParams.flags = layoutParams.flags or WindowManager.LayoutParams.FLAG_FULLSCREEN
    }
    activity.window.setAttributes(layoutParams)
    activity.window.decorView.systemUiVisibility = layoutParams.systemUiVisibility
}

参考文章

相关文章

自动化零件商城(www.rssme.com)专业PLC,变频器,直线模组,触摸屏,控制器,传感器等自动化商品网上购物商城,为广大中小工业企业提供优质、低价格和种类齐全的自动化零件。

暂无评论

评论审核已启用。您的评论可能需要一段时间后才能被显示。

none
暂无评论...