Is it possible to prevent the orientation of an Android application from changing ? I have an application that previews the phone camera and I would like the orientation not to change.
I have tried adding this to the manifest but it did not make a difference
<application android:label="TextureViewCameraStream" android:hardwareAccelerated="true"> </application> <activity android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden"> </activity>
I am using Xamarin for Android and C#
Thank you
Xamarin. Android supports several options for specifying orientation: Landscape – forces the application orientation to be landscape, regardless of sensor data. Portrait – forces the application orientation to be portrait, regardless of sensor data.
If you want to manually handle orientation changes in your app you must declare the "orientation" , "screenSize" , and "screenLayout" values in the android:configChanges attributes. You can declare multiple configuration values in the attribute by separating them with a pipe | character.
Set it in the Activity flag like this:
[Activity (Label = "YourActivityname", MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait)]
If you have an Activity, and you want to keep your activity in the same orientation when it is opened, then use this label:
[Activity(Label = "MyApp", ScreenOrientation = Android.Content.PM.ScreenOrientation.Locked)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With