2013-06-04 60 views
0

我想禁用手机和平板电脑landsacpe模式,但是当我在下面用这个代码,一个应用10" 运行的平板电脑,我得到倒置布局。如何禁用Android平板电脑的横向模式?

<activity android:name="com.zookey.mathgenius.activities.LocalGameActivity" 
android:screenOrientation="portrait"     
android:configChanges="orientation|keyboardHidden|keyboard"></activity> 

我该如何解决这个问题?

IMAGE:

dodaj.rs/f/2G/En/2lqYaW1v/inverted.png

+1

define'inverted layout'(你是否将你的平板电脑颠倒过来?) – njzk2

+0

你可以尝试'android:screenOrientation =“reversePortrait”'看看会发生什么。 –

+0

只是为了解......你能否提供一些你正在使用的硬件的细节?我的廉价中国平板电脑出现类似问题,但没有解决。 –

回答

0

以固定取向编程,你可以使用下面的代码:

//Disables screen orientation change based on sensor 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); 

//Sets the screen orientation to portrait 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

//Sets the screen orientation to inverted portrait 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); 

//Let system decide the orientation (when you are done) 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); 
+0

又一次。 – Zookey

+0

它同样适用于screen_orientation_portrait和screen_orientation_reverse_portrait?我希望您一次只使用其中一个选项;) –

+0

我尝试过使用以下方法://根据传感器禁用屏幕方向更改 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_N θ传感器); //将屏幕方向设置为纵向 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); – Zookey