Android app always vertical?

2

I want my APP to only run vertically but I can not, I have implemented the following without success.

Manifest:

< application
        ...
        android:configChanges="orientation"
        android:screenOrientation="portrait">

Activity:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    android:orientation="vertical">
    
asked by Antonio Ruiz 27.04.2018 в 17:56
source

1 answer

2

In your Mainfest.xml file find the tags of the activities you want to block in a given rotation.

You need to add all your activity to not only one, that is, set this for all your activities:

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

Explanation:

  
  • android:configChanges="orientation" will be responsible for the orientation changes.

  •   
  • android:screenOrientation="portrait" sets the default orientation mode.

  •   

Another way is:

Use setRequestedOrientation() as shown here:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
setContentView(R.layout.main);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    
answered by 27.04.2018 / 18:03
source