在程序中可以通過對Android:screenOrientation
的值設置的不同來控制顯示,通常在Androidmainfest中修改,將其設置爲activity中;如下所示
<activity
android:name="com.shzx.yyqg.ui.activity.MainActivity"
android:screenOrientation="portrait"//設置爲只能豎屏顯示
android:theme="@android:style/Theme.Black.NoTitleBar" >//隱藏標題欄
</activity>
Android:screenOrientation可以設爲以下屬性值
unspecified默認值
landscape橫向
portrait縱向
user用戶當前的首選方向
behind根據用戶的旋轉和手持設備方向來更改顯示方向
nosensor不根據用戶的旋轉和手持設備方向來更改顯示方向