如何锁定Android应用程序的方向为纵向模式?
问题描述:
我开发一个Android应用程序,其方向我不想改变为横向模式,当用户旋转设备。另外,我想锁定方位要对手机和平板电脑上的横向模式肖像模式。才能实现这一目标,如果是的话怎么样?谢谢你。
I am developing an Android app whose orientation I don't want changed to landscape mode when the user rotates the device. Also, I want the locked orientation to be portrait mode on phones and landscape mode on tablets. Can this be achieved, if yes how? Thanks.
答
只要你必须定义以下属性设置为您的活动里面清单文件
,它会限制你的活动为纵向。
Just you have to define below property to your activity inside manifest file
, It will restrict your activity to portrait.
安卓screenOrientation =画像
android:screenOrientation="portrait"
例:的
<activity
android:name="com.example.demo_spinner.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>