BASIL VARGHESE
BASIL VARGHESE

Reputation: 183

How to disable splash screen auto rotate in android app?

I need to disable splash screen auto rotate.

Need to show splash screen in portrait mode only. But app must rotate with auto rotate. How to do it in android studio ?

Upvotes: 2

Views: 3400

Answers (9)

Mr. Mad
Mr. Mad

Reputation: 1238

try this in manifiest

  <activity
    android:name=".SplashScreenActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait"/>

Upvotes: 0

Mithun Sarker
Mithun Sarker

Reputation: 4023

You Can do it by couple of ways

One

Inside the onCreate method of your activity

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

Two

In manifest file

   <activity
        android:name=".NameOfYourSplashScreenActivity"
        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>

Hope it helps

Upvotes: 3

Kush
Kush

Reputation: 1092

Add in Manifest file-->

    <application
    .........
    >

    <activity
                android:name=".SplashScreenActivity"
                  ......
                 android:screenOrientation="portrait"
                 />

</application>

or for horizontal mode

<activity
        ...
        ...
        android:screenOrientation="landscape">

Upvotes: 6

Nicola De Fiorenze
Nicola De Fiorenze

Reputation: 2128

In the manifest, set this for your splash screen activity:

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

Upvotes: 5

Dehan Wjiesekara
Dehan Wjiesekara

Reputation: 3182

Add following code to your splash screen activity declaration in Manifest

<activity android:name=".YourActivityName"
              android:label="@string/app_name"
              android:configChanges = "orientation"
              android:screenOrientation = "portrait">

or else add

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

to YourActivity.onCreate()

you can find a sample demo file here in github

Upvotes: 2

Juvi
Juvi

Reputation: 1338

Add to your splash activity declaration in the manifest this lines:

<activity
    android:name="SplashActivity"
    android:screenOrientation="portrait"
    android:configChanges="keyboardHidden|orientation|screenSize">

Find relevant discussion here.

Upvotes: 4

Vickyexpert
Vickyexpert

Reputation: 3167

Just add below line in your manifest file, in splash activity tag

  android:screenOrientation="portrait"

Something like below

    <activity
        android:name=".SplashActivity"
        android:screenOrientation="portrait" >

Upvotes: 4

Anirudh Sharma
Anirudh Sharma

Reputation: 7974

In manifest you can set the specific activity to be in portrait mode using

 android:screenOrientation="portrait"

Upvotes: 4

Arjun saini
Arjun saini

Reputation: 4182

In Your AndroidMainfest.xml put the screen orientation to your splash

     <activity
        android:name=".SplashScreenActivity"
        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>

Upvotes: 5

Related Questions