Pixels instead of dp in Designer

This has been known for a long time and is an issue that may never be solved.

I think @Boban was able to retrieve device dpi information through Javascript in a WebViewer.
Unfortunately, I have lost the thread.

What I meant was AI2 itself is unlikely to be updated. We will always need some work around or another.

Why should not be updaed anymore?

We'd have to really think that through. I think it makes perfect sense to have font size be sp and other pixels sizes be dp. sp scales with user-controllable settings such as system-wide font size, so it makes little sense to have font be anything else (read more here). Regarding dp, recall that App Inventor is intended for educational use, and imagine how complicated a classroom experience might be if everyone tries to follow a tutorial and due to the mix of device screen densities in the room get wildly different UI layouts. By keeping the pixels relatively sized based on density it alleviates those headaches. Changing the semantics to be raw pixels likely would break most existing apps, so there would need to be some other mechanism to do measurements in terms of raw pixels.

2 Likes

Maybe just a checkbox that would be checked by default. Checkbox checked - DP, unchecked - PX. I don't think it would spoil the existing projects.

Yes and no. Any extensions that manipulate visible components would also need to be updated to reflect this change.

2 Likes

I created an extension for DisplayMetrics:

1 Like

Galaxy Note 8 ........................................ Pixel 2XL

.....

1 Like

Very nice. Should be useful for resizing fonts.

Edit: Never mind, just realised it’s an apk and not an aix.

Could be useful if you publish the aix also, it looks good (apart the missing 'e' in Height but not so relevant).

Thanks for the hint. Spelling doesn't seem to be my forte - not even in my mother tongue (German). :upside_down_face:

I'll do it soon ...

It is a good news, well done Anke.

I increased the font size in the device settings:

1 Like

Hi Anke - could you add Height Millimeters and Width Millimeters to your extension please? A lot of us, especially young Europeans, think in metric.

Ok, done:

3 Likes

I released the extension.

1 Like

Nice one Anke :sunglasses:

1 Like

Good job Anke, soon I will write an example or a template using it and surely today I will run the apk on some smartphones to check their real "geometry" (I found a couple of info apps in the Google store that return not consistent data).