How do you prevent the android screen from turning to the side?

Whenever I rotate the device sideways, everything in my application also rotates and gets distorted. How to lock it vertically?

+1
source share
4 answers

In yours, AndroidManifest.xmlset the focus on your event to portraitlike this.

<activity android:name=".YourActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
+5
source

Whenever I rotate the device sideways, everything in my application also rotates and gets distorted. How to lock it vertically?

As a rule, you do not want to do this.

Firstly, some users have devices with physical keyboards that work only in landscape mode. Perhaps for your application this does not matter. However, any application that uses text input must support landscape mode for these users.

-, . , Google TV, Android.

-, , , .

, , Android Market.

, res/layout-land/ , .

+5

, , android:screenOrientation.

Set the value portraitor landscape. Make sure he is not sensor .

+1
source

Source: https://habr.com/ru/post/1782729/


All Articles