Hi harsha111111-5189,
Welcome to our Microsoft Q&A platform!
To achieve different layouts for portrait mode and landscape mode, you can refer to the document: Device Orientation, which makes it possible to design interfaces using the built-in layouts (StackLayout, AbsoluteLayout, RelativeLayout and Grid) so that they transition gracefully when the device is rotated.
And if you want to use "landscape" only in tablet, for Android, you can modify the MainActivity as follows to check if is a phone or not.
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (!isPad(this))
{
RequestedOrientation = ScreenOrientation.Portrait;
}
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
public static bool isPad(Context context)
{
return (context.Resources.Configuration.ScreenLayout & ScreenLayout.SizeMask) >= ScreenLayout.SizeLarge;
}
Then the "landscape" will be disabled for phone.
For iOS, to disable the "landscape" on iPhone, just modify the "Supported interface orientations" in info.plist as follows.
Last, make sure Auto-rotate is ON.
Regards,
Kyle
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.