How to force the Landscape/Landscape position?

Asked

Viewed 1,039 times

0

How to force the Paiage/Landscape position on my Activity forever active and lock the Portrait/Portrait position. I want my app to already start in landscape position and can’t turn to portrait position.

2 answers

3


In your Activity you need to put the following code in the onCreate method:

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);

Thus remaining:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sua_activity);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
  • 2

    Thanks buddy, it worked 100%

2

Hello, this can also be done on Androidmanifest, no need to do it in the code:

    <activity
        android:name="..."
        android:label=".."
        android:configChanges="orientation"
        android:screenOrientation="portrait">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.