xamarin forms use MainDisplayInfo.Density to calculate element width

246 Views Asked by At

I want to set the width and height of an element to be approx 1cm. On UWP, I've determined empirically that setting the element's WidthRequest and HeightRequest to 25 comes pretty close.

Using MainDisplayInfo.Density, I would think that I should be able to compute the right value for various displays.

On my UWP display, the Density is 1. On my Android device, it's 3. So, shouldn't a value of 25 * 3 = 75 be correct ?

Unfortunately that isn't working. On my Android device, 75 is is displaying my element at about 2cm.


EDIT

Further, XF documentation Units Of Measurement, says that there are 64 device independent units per cm. According to that, shouldn't I be setting my desired width and height to 64 ? Not even close.

0

There are 0 best solutions below