Android - Vertical layout only

How do I make sure my app is only for vertical layout?

I have tried android:screenOrientation="portrait" but that doesn't seem to do the trick.


You need to add to all your activity not for one only. I think you understood that setting is per application wide, but it isn't.

<activity android:name=".MyActivity"
          android:label="My Activity"
          android:screenOrientation="portrait">

Add the declaration to the activity tag in AndroidManifest for every Activity you want to be portrait-only.


If you want some group of your activities to be locked on PORTRAIT mode only, than you can choose the next way:

public abstract class BasePortraitActivity extends Activity {

    @Override
    protected final void onCreate(Bundle state) {
        super.onCreate(state);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        performOnCreate(state);
    }

    protected abstract void performOnCreate(Bundle state);

}

And than just extend BasePortraitActivity where you need it. Or just add setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); to YourActivity.onCreate().