zoukankan      html  css  js  c++  java
  • Android 全屏相关操作

    1.隐藏标题栏(titlebar)

      (1)在代码中隐藏标题栏

    requestWindowFeature(Window.FEATURE_NO_TITLE);

      (2)在Manifest中Application或Activity中配置主题样式

    android:theme="@android:style/Theme.NoTitleBar"

    2.隐藏状态栏(statusbar)
      (1)在Manifest中Activity中配置主题样式

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

      (2)在代码中隐藏状态栏

        /**
         * 隐藏状态栏
         */
        private void hideStatusBar() {
            //定义全屏参数
            int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
            //获得当前窗体对象
            Window window = MainActivity.this.getWindow();
            //设置当前窗体为全屏显示
            window.setFlags(flag, flag);
        }

    3.隐藏导航栏(NavigationBar)

       /**
         * 隐藏导航栏,可返回
         */
        private void hideNavigationBarCanBack() {
            View decorView = getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN;
            decorView.setSystemUiVisibility(uiOptions);
        }

    4.同时隐藏状态栏和导航栏

        /**
         * 隐藏导航栏
         */
        public void hideNavigationBarAndStatusBar() {
            int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN; // hide status bar
    
            if (android.os.Build.VERSION.SDK_INT >= 19) {
                //SYSTEM_UI_FLAG_IMMERSIVE_STICKY: hide navigation bars - compatibility: building API level is lower thatn 19, use magic number directly for higher API target level
                uiFlags |= 0x00001000;
            } else {
                uiFlags |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
            }
            getWindow().getDecorView().setSystemUiVisibility(uiFlags);
        }

    5.动态全屏与退出

        /**
         * 动态设置全屏
         */
        private void dynamicFullScreen(){
            WindowManager.LayoutParams attrs = getWindow().getAttributes();
            attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
            getWindow().setAttributes(attrs);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
    
        /**
         * 动态退出全屏
         */
        private void dynamicExitFullScreen(){
            WindowManager.LayoutParams attrs = getWindow().getAttributes();
            attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().setAttributes(attrs);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
  • 相关阅读:
    Windows Phone7官方更新 增加复制粘贴
    使Apache(Linux)支持Silverlight
    WPF触摸屏项目案例(放置在奔驰公司触摸屏展厅)
    项目开发项目管理(转)
    诺基亚WP7手机界面曝光
    Windows 8十大传言:令苹果坐立不安
    如何为 iPad 打造速度超快的 HTML5 软件
    Silverlight5.0正式发布附下载地址
    我们的案例请访问我们团队官网http://Silverlighter.net
    【转】NTFS3G的安装和配置
  • 原文地址:https://www.cnblogs.com/pillowzhou/p/4897334.html
Copyright © 2011-2022 走看看