美文网首页
andriod全屏设置

andriod全屏设置

作者: 一毫米距离 | 来源:发表于2017-12-08 15:42 被阅读17次

    andriod 全屏 窗口全屏 活动全屏 窗口全屏是指隐藏系统顶部的时间 电量,活动全屏指的是隐藏活动的标题栏

    窗口全屏 代码如下

        /* 全屏显示 */
        public static void setFullscreen(final Activity context) {
            final Window win = context.getWindow();
            final WindowManager.LayoutParams winParams = win.getAttributes();
            final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
            winParams.flags |= bits;
            win.setAttributes(winParams);
        }
    

    窗体全屏

    方式一

        protected void onCreate(final Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
                   //该行代码必须在setContentView之前
                    requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_login);
        }
    
    

    方式二

            <activity
                android:name=".activities.LoginActivity"
                android:label="@string/app_name"
                android:screenOrientation="portrait"
                android:theme="@android:style/Theme.Light.NoTitleBar" >
            </activity>
    

    andriod系统版本和对应的API

    系统版本 API cat
    4.0.03-4.0.04 15 foo
    4.1 16 bar
    4.2 17 baz
    4.3 18 bar
    4.4 19 baz
    5.0 21 bar
    5.1 22 baz
    6.0 23 bar
    7.0 24 baz
    7.1 25 baz
    8 26 baz

    获取LayoutInflater方法

    1.(LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)

    2.LayoutInflater.from(activity);

    Dialog 对话框样式

        <style name="progress_style" parent="@android:Theme.Dialog">
            <!-Dialog的windowFrame框为无->
            <item name="android:windowFrame">@null</item>
            <!-Dialog的Title->
            <item name="android:windowNoTitle">true</item>
            <!-Dialog否浮现在activity之上->
            <item name="android:windowIsFloating">true</item>
            <item name="android:windowContentOverlay">@null</item>
            <!-Dialog背景颜色->
    
            <item name="android:windowBackground">@android:color/transparent</item>
        </style>
    

    获取SharedPreferences

            final SharedPreferences sh = context.getSharedPreferences(DESIRED_PREFEREVCE_FILENAME, Context.MODE_PRIVATE);
            final Editor editor = sh.edit();
            editor.putString(Key.UserMenulist, authorizeData.getMenuList());
    
            editor.commit();
    

    相关文章

      网友评论

          本文标题:andriod全屏设置

          本文链接:https://www.haomeiwen.com/subject/dzveixtx.html