Android 设定横屏,禁止屏幕旋转,Activity重置 [更新视频播放器相关]
1. 设定屏幕方向
当指定了屏幕的方向后(非SCREEN_ORIENTATION_UNSPECIFIED),屏幕就不会自己主动的旋转了
有2中方式控制屏幕方向:
1.1 改动AndroidManifest.xml
1.2 setRequestedOrientation
横屏:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
竖屏:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
ActivityInfo:
|
int |
Constant corresponding to behind in the screenOrientation attribute. |
|
|
int |
Constant corresponding to fullSensor in the screenOrientation attribute. |
|
|
int |
Constant corresponding to fullUser in the screenOrientation attribute. |
|
|
int |
Constant corresponding to landscape in the screenOrientation attribute. |
|
|
int |
Constant corresponding to locked in the screenOrientation attribute. |
|
|
int |
Constant corresponding to nosensor in the screenOrientation attribute. |
|
|
int |
Constant corresponding to portrait in the screenOrientation attribute. |
|
|
int |
Constant corresponding to reverseLandscape in the screenOrientation attribute. |
|
|
int |
Constant corresponding to reversePortrait in the screenOrientation attribute. |
|
|
int |
Constant corresponding to sensor in the screenOrientation attribute. |
|
|
int |
Constant corresponding to sensorLandscape in the screenOrientation attribute. |
|
|
int |
Constant corresponding to sensorPortrait in the screenOrientation attribute. |
|
|
int |
Constant corresponding to unspecified in the screenOrientation attribute. |
|
|
int |
Constant corresponding to user in the screenOrientation attribute. |
|
|
int |
Constant corresponding to userLandscape in the screenOrientation attribute. |
|
|
int |
Constant corresponding to userPortrait in the screenOrientation attribute. |
2. 禁止 屏幕旋转后重置Activity
屏幕旋转后会强制调用Activity.onCreate方法,所以会重置Activity
禁止方法:
改动AndroidManifest.xml
android:configChanges=”orientation”
近期在做Android的播放器。遇到採用以上方法后,仍然出现屏幕旋转后触发Activity.onCreate,经查阅资料后,发现须要加入screenSize处理
详细代码为:
android:configChanges="orientation|keyboardHidden|screenSize"
禁止重置Activity会造成Screen的宽高颠倒, 须要手动修正。
Android 设定横屏,禁止屏幕旋转,Activity重置 [更新视频播放器相关]的更多相关文章
- 【转】如何在 Android 程序中禁止屏幕旋转和重启Activity
原文网址:http://www.cnblogs.com/bluestorm/p/3665890.html 禁止屏幕随手机旋转变化 有时候我们希望让一个程序的界面始终保持在一个方向,不随手机方向旋转而变 ...
- 如何在 Android 程序中禁止屏幕旋转和重启Activity
禁止屏幕随手机旋转变化 有时候我们希望让一个程序的界面始终保持在一个方向,不随手机方向旋转而变化:在AndroidManifest.xml的每一个需要禁止转向的Activity配置中加入android ...
- Android 禁止屏幕旋转 & 旋转屏幕时保持Activity内容
Android 禁止屏幕旋转 & 旋转屏幕时保持Activity内容 1.在应用中固定屏幕方向. 在AndroidManifest.xml的activity中加入: ...
- Android 禁止屏幕旋转、避免转屏时重启Activity
一.禁止屏幕旋转 在AndroidManifest.xml的每一个需要禁止转向的Activity配置中加入android:screenOrientation属性: 可选项: landscape = 横 ...
- Qt for Android 程序禁止屏幕旋转
有时候我们希望让一个程序的界面始终保持在一个方向,不随手机(平板)方向旋转而变化:在AndroidManifest.xml的每一个需要禁止转向的Activity配置中加入 android:screen ...
- 禁止屏幕旋转并同时解决以至于导致Activity重启的方法
1.禁止屏幕旋转在AndroidManifest.xml的每一个需要禁止转向的Activity配置中加入android:screenOrientation属性. //landscape(横向)port ...
- ionic2/3 禁止屏幕旋转,禁止横屏,竖屏
ionic2/ionic3禁止屏幕旋转,及解除禁止旋转 1.添加插件: cmd到项目目录---> cordova plugin add cordova-plugin-screen-orienta ...
- ios6和ios7禁止屏幕旋转
ios6和ios7禁止屏幕旋转 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOr ...
- 【Android】11.3 屏幕旋转和场景变换过程中GridView的呈现
分类:C#.Android.VS2015: 创建日期:2016-02-21 一.简介 实际上,对于布局文件中的View来说,大多数情况下,Android都会自动保存这些状态,并不需要我们都去处理它.这 ...
随机推荐
- doc下设置永久环境变量的好方法
http://www-2w.blog.163.com/blog/static/97931518201021211123267/ 需要查看命令具体实现:setx machine “%path%”. 配置 ...
- Linux进程间通信(IPC)
linux下的进程通信手段基本上是从Unix平台上的进程通信手段继承而来的.而对Unix发展做出重大贡献的两大主力AT&T的贝尔实验室及BSD(加州大学伯克利分校的伯克利软件发布中心)在进程间 ...
- 九度oj 题目1361:翻转单词顺序
题目描述: JOBDU最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上.同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思.例如,“stu ...
- Codeforces Round #345 (Div. 2)——B. Beautiful Paintings(贪心求上升序列个数)
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 兼容ie8 rgba()写法
background: rgba(255,255,255,.1); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#1 ...
- axis2生成webservice服务端返回String[]和String[][]一维数组和二维数组解析
环境:用axis2生成服务端,用aixs做客户端 1:直接返回String[]: public String[] testArr(String name) { String[] ret=new Str ...
- bzoj 2794 [Poi2012]Cloakroom 离线+背包
题目大意 有n件物品,每件物品有三个属性a[i], b[i], c[i] (a[i]<b[i]). 再给出q个询问,每个询问由非负整数m, k, s组成,问是否能够选出某些物品使得: 对于每个选 ...
- 【BZOJ4945&&UOJ317】游戏(2-sat,拓扑序)
题意: 思路: 输出方案时有一个优秀的性质可以利用: tarjan缩点之后点所属的分量编号是原图的反的拓扑序 所以只需要在两种方案内找到所属分量编号较小的那个就行了,用来满足(i,i')那个限制 #i ...
- linux 时间模块 三
LINUX的时钟中断中涉及至二个全局变量一个是xtime,另一个则是jiffies.有一个与时间有关的时钟:实时时钟(RTC),这是一个硬件时钟,用来持久存放系统时间,系统关闭后靠主板上的微型电池保持 ...
- wpf LookUpEdit PopupContentTemplate
<dxg:LookUpEdit Name="searchLookUpEdit" HorizontalAlignment="Stretch" PopupHe ...