How can I set Android app in PORTRAIT mode only?

You must Login before you can answer or comment on any questions.

There must be 100 question about this, but nothing works for me.

I wan't my app to be in PORTRAIT mode only. I tried

win.orientationModes = [Titanium.UI.PORTRAIT];

and it is not working.

Why can't I just configure this in tiapp.xml like on iOS.

It is stupid to touch AndroidManifest.xml which changes after each build.

3 Answers

Accepted Answer

You don't have to touch AndroidManifest.xml each time. You can put the necessary directives into tiapp.xml. See this thread

— answered 2 years ago by Jason Priebe
answer permalink
12 Comments
  • I tried this:

    <android xmlns:android="http://schemas.android.com/apk/res/android">
            <manifest>
                <application>
                    <activity android:name="org.appcelerator.titanium.TiActivity" 
                        android:screenOrientation="portrait" 
                        android:configChanges="keyboardHidden|orientation">
                    </activity>
                </application>
            </manifest>
        </android>
    but it is not working...

    — commented 2 years ago by Dino Bartosak

  • I can force my window to be in portrait mode with win.orientationModes = [Titanium.UI.PORTRAIT];

    But if I start my app in lanscape mode, then splash screen is landscape and my window gets confused.

    This is really frustrating now...

    — commented 2 years ago by Dino Bartosak

  • You need to specify the orientation for all of the <activity> nodes that are specified in the AndroidManifest.xml. I'm fairly certain you have some other activities defined in your AndroidManifest.xml.

    — commented 2 years ago by Jason Priebe

  • Show 9 more comments

It should be like -

<activity android:name="org.appcelerator.titanium.TiActivity" android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" /> <activity

Try this -

android:screenOrientation="portrait" . It is working fine for me

— answered 2 years ago by Jyoti Gupta
answer permalink
2 Comments
  • I've seen this on many places but nowhere says where should I put in. AndroidManifest.xml? tiapp.xml? In which tag? Android really messed with this one.

    — commented 2 years ago by Dino Bartosak

  • Put it in tiapp.xml

    — commented 2 years ago by Jyoti Gupta

Your Answer

Think you can help? Login to answer this question!