0

I'm developing an Android application, and I don't like it to rotate when the user rotates the screen. The user will be able to use only the portrait view, but not the landscape one.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
KrithGhosh
  • 88
  • 1
  • 5

5 Answers5

16

Put the following in your manifest, in every activity that should not rotate:

<activity
    ...
    android:screenOrientation="portrait" />
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hans1984
  • 796
  • 11
  • 24
2

Add this below code in your activity from AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YourPackage.name">

    //Other Activities and Intents

    <activity
        //Other lines of your activity code
        android:screenOrientation="portrait">
    </activity>
</manifest>

Tell me if I helped you and good programming!

PD: Next time searches a little in this community or in Internet, because it's a typical question and you can find a lot of answers from this and others problems, thanks!

2

You have to declare all the limitations/permissions in your manifest file. Just add the following permission for your application.

android:screenOrientation="portrait"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Esha
  • 76
  • 1
  • 8
1

In your manifest, in the activity tag, use:

android:screenOrientation="portrait"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ahmed Basyouny
  • 343
  • 3
  • 11
0

Add in manifest android:screenOrientation to your app.

<activity android:name="YourActivity" android:screenOrientation="portrait" > (...) </activity>
krystian71115
  • 1,927
  • 17
  • 36