i need to change the orientation as per tablet (both orientations) for Phone (only portriat) , kindly let me know the ways to do it in MVVM Cross in Android
[Activity(ScreenOrientation = ScreenOrientation.Portrait, Theme = "@style/AppTheme")]
Put this bool resource in res/values
as devices_config.xml
or whatever (file names don't matter here):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="portrait_only">true</bool>
</resources>
Put this one in res/values-sw600dp
and res/values-xlarge
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="portrait_only">false</bool>
</resources>
Then, in the OnCreate
method of your Activities you can do this:
if (Resources.GetBoolean(Resource.Boolean.portrait_only))
{
RequestedOrientation = ScreenOrientation.Portrait;
}
Devices that are more than 600 dp in the smallest width direction, or x-large on pre-Android 3.2 devices (tablets, basically) will behave like normal, based on sensor and user-locked rotation, etc. Everything else (phones, pretty much) will be portrait only.
Based on this answer
Just in case, it's possible that you see some autorotations when changing activities, so if that's the case you can check this answer to fix it
HIH