博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android 横屏竖屏处理--禁止横屏
阅读量:5310 次
发布时间:2019-06-14

本文共 1590 字,大约阅读时间需要 5 分钟。

 

如果要定死横屏或者竖屏,不让它在用户旋转屏幕时改变:就用screenOrientation

 

 如果要做相应处理,就配置android:configChanges

For example, the following manifest code declares an activity that handles both the screen orientation change and keyboard availability change:

Now, when one of these configurations change, MyActivity does not restart. Instead, the MyActivity receives a call to . This method is passed a object that specifies the new device configuration. By reading fields in the , you can determine the new configuration and make appropriate changes by updating the resources used in your interface. At the time this method is called, your activity's  object is updated to return resources based on the new configuration, so you can easily reset elements of your UI without the system restarting your activity.

Caution: Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the  and  attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSize". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

 

注意在API level 13以上, 要加上screenSize

转载于:https://www.cnblogs.com/vivid-stanley/archive/2012/02/15/2352232.html

你可能感兴趣的文章
TCP粘包拆包问题
查看>>
Java中Runnable和Thread的区别
查看>>
SQL Server中利用正则表达式替换字符串
查看>>
POJ 1015 Jury Compromise(双塔dp)
查看>>
论三星输入法的好坏
查看>>
Linux 终端连接工具 XShell v6.0.01 企业便携版
查看>>
JS写一个简单日历
查看>>
LCA的两种求法
查看>>
Python 发 邮件
查看>>
mysql忘记密码的解决办法
查看>>
全面分析Java的垃圾回收机制2
查看>>
[Code Festival 2017 qual A] C: Palindromic Matrix
查看>>
修改博客园css样式
查看>>
Python3 高阶函数
查看>>
初始面向对象
查看>>
docker一键安装
查看>>
leetcode Letter Combinations of a Phone Number
查看>>
Unity 5.4 测试版本新特性---因吹丝停
查看>>
7.5 文件操作
查看>>
DFS-hdu-2821-Pusher
查看>>