Device: HTC Desire
I'm developing an app. It's hard to design the landscape mode, so I'd like to make it possible only for the portrate mode.
<application
android:debuggable="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:screenOrientation="portrait">
So I added it to the manifest file, but it doesn't work on my device. So I looked up other sites
<application
android:debuggable="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:configChanges="orientation"
android:screenOrientation="portrait">
You do that in the manifest file and put the code below in the activity class.
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Even if you do this, if you flip the device, it goes horizontally and vertically. How do I fix it?
android screen orientation landscape portrait
Instead of putting screen Orientation in the element of the application, put it in the element of activity. And put configChanges like the code below.
<activity
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
</activity>
© 2024 OneMinuteCode. All rights reserved.