Width and height of the screens

Can someone tell me how to make the picture a background for the page so that it displays correctly on all devices. Everything is clear about 1x, 2x, 3x images, but what about the width and height of the screens? How is this implemented?

Answers

  • Dinesh_OfficialDinesh_Official Member ✭✭✭
    edited January 27

    @Artuhovchik , you can use the https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.page.backgroundimagesource?view=xamarin-forms property to achieve your requirement.

    If you want height and width of the page, you can get those values in OnSizeAllocated override method of a Page.

  • ArtuhovchikArtuhovchik Member
    @Dinesh_Official, So, should I get a screen resolution and pick him a picture with the desired resolution from the resources?
  • LeoZhuLeoZhu Member ✭✭✭

    It will automatically select pictures of x1,x2 and x3 based on your device, you don't need to set it manually ,and in Android,it will also select the pictures in drawable-hdpi,drawable-xxhdpi ,drawable-xxhdpi ,drawable-xxxhdpi folders automatically base on the device resolution

  • Dinesh_OfficialDinesh_Official Member ✭✭✭

    @LeoZhu said:
    It will automatically select pictures of x1,x2 and x3 based on your device, you don't need to set it manually ,and in Android,it will also select the pictures in drawable-hdpi,drawable-xxhdpi ,drawable-xxhdpi ,drawable-xxxhdpi folders automatically base on the device resolution

    @Artuhovchik , yes.

Sign In or Register to comment.