修复屏幕方向 [英] Fix Screen orientation

查看:285
本文介绍了修复屏幕方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修复屏幕方向为横向模式在标签上即7
我计算我的编码装置的英寸并且将其设置为:

I wanted to fix screen orientation as a landscape mode in tab i.e on 7" I am calculating the inch of the device in my coding and is setting it as:

int inch=((int)height_pixel1/(int)xdpi);
if(inch>=6){
    orientation=true;
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
    orientation=false;
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

和问题首先是它显示我的屏幕方向是按照我的要求,但在处理两者之间怎么回事,然后在横向的方式改变了方向人像方式再次..它仍然是这些之间切换两个指向,我想打一个固定orienattion为我的整个应用程序...有没有,我在这里失踪?任何财产

and the problem is firstly it displays me the screen orientation as according to my requirement,but when processing is going on in between , then it changes the orientation as portrait way and again in landscape way.. It is still toggle between these two orientation and I want to make a fixed orienattion for my whole application...Is there any property that I am missing here??

推荐答案

创建一个文件夹布局XLARGE土地,并把你的XML在它...它应该被设计为landsacpe屏..还你必须给

Create a folder layout-xlarge-land and put your XML in it... it should be designed for landsacpe screen.. also You have to give

android:largeScreens="true"  in manifest... 


res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation





 <supports-screens android:resizeable=["true"| "false"]
                      android:smallScreens=["true" | "false"]
                      android:normalScreens=["true" | "false"]
                      android:largeScreens=["true" | "false"]
                      android:xlargeScreens=["true" | "false"]
                      android:anyDensity=["true" | "false"]
                      android:requiresSmallestWidthDp="integer"
                      android:compatibleWidthLimitDp="integer"
                      android:largestWidthLimitDp="integer"/>

请参阅
http://developer.android.com/guide/topics/resources/providing -resources.html

这篇关于修复屏幕方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆