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.

4 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 3 years ago by Jason Priebe
answer permalink
  • I tried this:

    <android xmlns:android="">
                    <activity android:name="org.appcelerator.titanium.TiActivity" 
    but it is not working...

    — commented 3 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 3 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 3 years ago by Jason Priebe

  • Show 10 more comments

It should be like -

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

The issue lies with the name of the activity. Many people are using the default name which starts with a period (Ex. android:name='.MyAppActivity'). You should be using the base class name for the activity org.appcelerator.titanium.TiActivity.


Try this -

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

— answered 3 years ago by Jyoti Gupta
answer permalink
  • 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 3 years ago by Dino Bartosak

  • Put it in tiapp.xml

    — commented 3 years ago by Jyoti Gupta

Your Answer

Think you can help? Login to answer this question!