Slamit
Slamit

Reputation: 553

screen orientation - reverse portrait

I have a very basic layout with a Frame and a TextView. When I put my phone upside down (reverse portrait) the Text is not facing me, the screen does not rotate. Is it en intended behavior that by default the screen only rotate in 3 direction?

<TextView
    android:text="Text"
    android:textAlignment="center"
    android:textSize="70dp"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"/>

Manifest:

<activity
        android:name=".Menu"
        android:screenOrientation="user"/>

From what I could gather through researches it is part of the default settings of recent android OSs. Would I need to program anything complex to get this working? Or a small setting would do the job (like adding a layout)?

I target OS 5+ (API 21)

Upvotes: 2

Views: 1279

Answers (1)

Charuka Silva
Charuka Silva

Reputation: 13153

In your AndroidManifest.xml file, you need to configure the <activity> to use the orientation from the sensor. This should be the default, but you can force it to the sensor's orientations, for all 4 possible orientations, with android:screenOrientation="fullSensor"

<activity
            android:name=".ui.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="fullSensor"
            android:theme="@style/AppTheme.NoActionBar" />

Upvotes: 4

Related Questions