Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Portrait only not working?

Hello,

I'm working on my first app, and i'm already having trouble. I set the screen orientation to "portrait" for both activities but it still rotates when I rotate the phone, I noticed the same thing happening in the interactive story app (for me at least).

Code:

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".NewActivity"
                  android:screenOrientation="portrait">
        </activity>
    </application>

Please help!

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

Hi Diego - In the code you've posted you haven't set the screen orientation to "portrait" for MainActivity.

Thanks once again Kourosh! :)