[Feature request] Introduce helper to determine if an Xamarin.Forms app runs on a Duo device

Frequent Contributor

Idea

The large screens of the Duo are able to present more information than any other "single" screen Android device.

 

That's why I need to know if the app is running on a Surface Duo or not. In my optionen, please correct me if this feature already exists, a simple member provided by the SDK that indicatates if it is running on a Duo would be great.

 

Example extension

 

public static class DualScreenInfoExtensions
{
    public static bool IsDuo(this DualScreenInfo dualScreenInfo)
    {
        return DualScreenInfo.Current.HingeBounds.Width != 0;
     }
}

 

 

Example usage

For example to show a multi column layout for "is a Duo" and a single column layout for "is not a Duo"

 

if(DualScreenInfo.Current.IsDuo())
{
    SecondColumnWidth = new GridLength(1, GridUnitType.Star);
}
else
{
    SecondColumnWidth = new GridLength(0, GridUnitType.Absolute);
}

**GitHub**

I also created an issue in the Xamarin Surface Duo samples repository.

 

1 Reply

Hey @tscholze, I also posted on the samples issue, but I recommend this request go on the Xamarin.Forms open-source repo, as it will be most visible to the team.

 

https://github.com/xamarin/Xamarin.Forms/issues