• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps programmatically configure orientation

yairov

Lurker
is there a way to programmatically configure orientation in android application at runtime ?

(I want to allow portrait in phones and portrait/landscape in tablets)
 
In your project, in the Android Manifest file, under the activity section is where you would dictate which orientation you want the app to start in.

for example:
android:screenOrientation="portrait" would lock your app into portrait mode.
android:screenOrientation="landscape" would lock your app into landscape mode.

Code:
<activity
            android:name=".Game"
            android:label="GAME"
                  android:configChanges="keyboard|keyboardHidden|orientation"
            android:screenOrientation="portrait">
            </activity>

If you want to do both landscape and portrait for different devices, then the code is similar just placed in different areas.
 
Back
Top Bottom