设置横竖屏切换及全屏显示

在安卓xml文件中更改横竖屏切换

  <activity
            android:name=".MainActivity"
            android:label="@string/app_name" 
            android:screenOrientation="landscape"
            android:configChanges="keyboardHidden|orientation" 
            >
            <!-- 
            android:screenOrientation="portrait" 竖屏
            android:configChanges="keyboardHidden|orientation" 
                                             这两句为设置横屏和竖屏,在屏幕切换的时候默认为重新走OnCreate方法 
                                          当设置了configChange之后就不会再重新走onCreate方法 
             -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

这代码中更改横竖屏切换

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

在xml文件中添加全屏显示

 <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar" >
        <activity

在代码中添加全屏显示

//全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //去标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);

《Android版本更新、热更新》系列课程视频

版本更新6.0,7.0统统搞定!!

热修复不在麻烦,再也不用担心上线后出bug!!

http://edu.youkuaiyun.com/course/detail/6523

http://edu.youkuaiyun.com/course/play/6523/131198

《Kotlin语法基础到实战开发》系列课程视频

http://edu.youkuaiyun.com/course/detail/6409?locationNum=7&fps=1&ref=srch&loc=1

http://edu.youkuaiyun.com/course/play/6409/123752

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值