出自http://eigo.co.uk/News-Article.aspx?NewsArticleID=103
How to lock the orientation
In the onCreateDialog(int) event of the activity use the setRequestedOrientation(int) method to set the screen orientation to your chosen setting. The activity will stay in this orientation regardless of if the device is tilted or not.
[Code sample – How to lock the orientation] |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } |
How to detect the current orientation
To programmatically detect the current orientation of the activity use the following code snippet. The orientation property of the Configuration class returns three possible values corresponding to Landscape, Portrait and Square.
[Code sample – How to detect the current orientation] |
switch (this.getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_PORTRAIT: // Do something here break; case Configuration.ORIENTATION_LANDSCAPE: // Do something here break; case Configuration.ORIENTATION_SQUARE: // Do something here break; default: throw new Exception("Unexpected orientation enumeration returned"); break; } |
Example : Locking rotation while performing an action.
You might wish to disable the screen rotation whilst performing an action or by user command, to do this you need to combine the above samples to detect the current orientation and lock the display to that orientation.
[Code sample – Locking rotation while performing an action] |
// Sets screen rotation as fixed to current rotation setting private void mLockScreenRotation() { // Stop the screen orientation changing during an event switch (this.getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_PORTRAIT: this.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case Configuration.ORIENTATION_LANDSCAPE: this.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; } } |
Once your action has completed you may wish to enable screen rotation again, see the next section for an example on how to do this.
How to re-enable screen rotation
To enable the orientation to be automatically changed on device tilt simply pass thesetRequestedOrientation(int) method the enumeration value for an unspecified orientation.
[Code sample – How to re-enable screen rotation] |
// allow screen rotations again this.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); |
异步处理 的时候如果转屏 异步处理就会停止,附件就是防止这种情况发生
分享到:
相关推荐
当我们观看视频时,往往喜欢切换到横屏模式,那当屏幕旋转时,如何使视频全屏显示?
//转屏事件,内部功能可以自定义 function screenOrientationEvent(){ if(orientation == 0)document.getElementById("change").value="竖"; else document.getElementById("change").value="横"; } var ...
TIA博途中触摸屏TP1200更换为TP900时,画面超出界面的处理办法 触摸屏型号替换 画面超过界面
比较好地解决用宽屏LCD玩老游戏时,游戏画面意外拉伸造成的画质下降和画面变形问题。希望本文能对遇到类似问题的朋友有所帮助,并更好地“驾驭”自己的宽屏LCD,看得更宽、看得更多、用得更爽!
现如今很多场所都在使用液晶拼接屏,有时我们会看到业务在...数字屏幕直接输入数字信号,RGB的每个颜色信号由视频处理电路转换成数字信号,并直接发送到屏幕上的控制驱动器,并在前一电路中完成A / D转换。模拟屏输入是
而触摸屏处理的数据是点的物理坐标,该坐标是通过触摸屏控制器采集得到的。要想实现触摸屏上的物理坐标与LCD上的像素点坐标一一对应上,两者之间就需要一定的转换,即校正。而且电阻式触摸屏由于自身的原因参数会...
是一款短小精悍易于使用的图像处理工具箱,内置图像处理、gif动画制作、图片格式转换、屏幕录像、幻灯片制作、以及视频转图像共计六个超级实用的工具,旨在于帮助没有特殊技能的用户在编辑照片或图像时快速进行必要...
MSAutoLayout 利用Masonry实现屏幕尺寸适配和横竖转屏,cell根据文字内容实现高度宽度自适应 #视频演示 第一次上传... :grinning_face_with_smiling_eyes:
中文名: 别说你懂Excel:500招玩转Excel表格与数据处理(附完整光盘数据) 作者: 前沿文化图书fenlei: 软件 资源格式: PDF 版本: 扫描版 出版社: 科学出版社书号: 9787030371782发行时间: 2013年05月 地区: 大陆 语言:...
然后转世界坐标。如果pointsize过大,精度会有一定损失。为1时精度在小数点后两位。当鼠标move到点上时,控制台输出原始点 x y z的坐标信息。窗口不要改动,resizeGL函数中没有对纹理进行处理。
,四线电阻式触摸屏:电阻触摸屏的屏体部分是一块与显示器表面非常配合的多层四线/触摸屏控制复合薄膜,由一层玻璃或有机玻璃作为基层,表面涂有一层透明的导电层,上面再盖有一层外表面硬化处理、光滑防刮的塑料层而...
ABB新示教器屏幕校准
Android应用中,图片随手势的拖拽、缩放、旋转在很多场景中都会用到,今天我们要做的就是在ImageView的基础上实现一个可以拖拽、缩放、转转的TouchView。
这是一个博物馆展台项目,可以通过触摸屏来选择显示展品信息。当展品转动到当前位置后,可以通过串口发送数据
软件内置功能完善的图像编辑器,除提供缩放、旋转、剪切、格式转换、调整大小等基本功能外,还可向图像中加入标题、边框和水印、文本与线条、自定义图形等内容,并可调整图像颜色和进行多种特效处理;可处理几乎...
一个非常优秀的屏幕转换成AVI文件的程序
YCbCr444转YCbCr422编码,用于PAL、NTSC格式输出。
吉大图像处理软件是一款免费图像处理软件。它是一款容易使用的图像编辑、图像处理软件,上仅具有常见的图像裁剪、图像旋转、图像拼接、灰度处理、马赛克、消除红眼等等基本的图像处理功能,而且还有强大的特色功能。...
转换ANSI 屏幕到RIP格式(17KB)