2013-01-23 23 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