Android. Lock orientation of screen for all Activi

2019-02-16 17:31发布

Possible Duplicate:
How can I set Orientation Fixed for all activities

I would like to lock my screen orientation for my app. I mean that all Activities must have the same landscape orientation. I don't want to add android:screenOrientation="portrait" in the manifest for all activities. Is there any other way? thanks Regards

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-02-16 17:38
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation"

Add the above lines in your app's manifest for all the activities .

查看更多
霸刀☆藐视天下
3楼-- · 2019-02-16 18:01

You have two options for achieving the result.

  • You can specify per activity base orientation requirement in manifest file. You can select here what orientation you want to support for which activity.

e.g.

<activity
    android:name=".Some_Act"
    android:label="@string/app_name"
    android:screenOrientation="portrait" >
</activity>
  • You can create a base activity and specify the orientation in that activity. Later you can inherit that activity in other activities of your application. You can choose suitable base class to get the desired behavior.
查看更多
登录 后发表回答