2013-01-23 22 views
1

我设置了必须的活动风景定位。它锁定屏幕,然后在活动中解锁屏幕。在android中的风景和人像定位

但现在活动画面已从肖像变为风景。

也就是说,锁定屏幕后,它将从横向变为纵向。

在我设置活动横向方向强制性后,如何始终保持景观?即使是锁定屏幕。

+0

要在一个特定的方向锁定,您必须在manifest文件中指定。 – pvn

回答

1

在AndroidMainfest.xml

<activity 
     android:name=".path.to.Activity" 
     android:configChanges="orientation" 
     android:screenOrientation="landscape" > 
1

您可以使用您的活动像这样的setRequestOrientation()方法调用程序强制方位的改变。

的纵向

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

&横向打印

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 

OR

如果你要修复的方向添加清单筛选

<activity 
     android:name=".activity.MainActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" 
     android:configChanges="orientation"> 

编辑:

更多详细信息,请参阅该链接

http://developer.samsung.com/android/technical-docs/Handling-Orientation-in-Android