Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 固定屏幕方向_Android_Android Layout_Android Manifest - Fatal编程技术网

Android 固定屏幕方向

Android 固定屏幕方向,android,android-layout,android-manifest,Android,Android Layout,Android Manifest,我想将屏幕方向固定为选项卡中的横向模式,即7“ 我正在计算编码中设备的英寸,并将其设置为: int inch=((int)height_pixel1/(int)xdpi); if(inch>=6){ orientation=true; this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { orientation=false; this.setRequ

我想将屏幕方向固定为选项卡中的横向模式,即7“ 我正在计算编码中设备的英寸,并将其设置为:

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);
}

问题是,首先它根据我的要求显示屏幕方向,但在处理过程中,它会将方向更改为纵向方向,然后再更改为横向方向。它仍然在这两个方向之间切换,我想为我的整个应用程序做一个固定的方向…有什么问题吗我在这里缺少的属性???

尝试一下,只需在AndroidManifest.xml文件中设置它:

<activity android:name=".ActivityName"
              android:label="@string/app_name"
              android:configChanges="orientation|keyboardHidden">  
              // Prevent application restart on orientation change

//防止在方向更改时重新启动应用程序

创建一个文件夹布局xlarge land并将XML放入其中…它应该是为Landscape屏幕而设计的。此外,您还必须

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"/>
清单中的android:largeScreens=“true”。。。 res/layout/my_layout.xml//正常屏幕大小的布局(“默认”) res/layout small/my_layout.xml//小屏幕布局 res/layout large/my_layout.xml//大屏幕布局 res/layout xlarge/my_layout.xml//超大屏幕布局 res/layout xlarge land/my_layout.xml//面向景观的超大布局 参考
请看一下这个

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
。。。。。。。。。。。。。。。
它将处理您的屏幕

否…因为此应用程序在7英寸选项卡上运行,也在手机上运行。因此我想将方向设置为7英寸的横向“tab和portait在移动设备上..因此,如果我将此屏幕定向应用为清单中的portait,则它将仅在portait模式下显示应用程序,而不是在横向模式下..但我想修复方向,我不希望它更改..在移动设备上,它在纵向模式下工作正常,但在7“Tab,它是在方向之间切换……我工作的OS是2.2,所以它显示它不支持XLabeSeCiS..然后你使用布局大的土地也给予:Android:大屏幕=“true”它将承担大屏幕从5”所以它也会考虑HTC欲望高清在大屏幕上显示景观模式..但是我只想要7和10.1英寸标签,仅适用于横向模式。Kanika如果您得到答案,请标记正确的答案