nico
April 6, 2025, 6:18am
1
Hello, in my application I am using 2 extensions : ✨ Card View Extension for MIT App Inventor and FloatingActionButton - Color, Size, Radius, Position & Icons. . However, depending on my screen quality (which I can adjust from HD+ to WQHD+), the FAB size and paddings/margins do not seem the same even though the code is the same.
Here in WQHD+
And here in HD+
What can I do to fix this problem?
Thanks in advance,
Nico
set the size by screen width's percentage?
nico
April 6, 2025, 9:30am
3
Yes, I defined the FAB size like this: size = screen1.width × 0.4
Your image looks not like 40%.
nico
April 6, 2025, 10:15am
5
Exactly! The problem is here. When I set 40%, it doesn't show me 40%...
TIMAI2
April 6, 2025, 10:17am
6
Please show your relevant blocks
TIMAI2
April 6, 2025, 10:21am
8
Are those blocks in the Screen.Initialise event ? (It always helps to show all your relevant blocks !!)
If so, it could be that AI2 has not had enough time to set the width/height properties of the screen.
Use a clock timer with interval of 100ms (adjust as necessary), and place your extension blocks to create the floating button in the Clock timer.
nico
April 6, 2025, 12:28pm
9
I don't think that's the problem because this block is located at the very end of a UI initialization procedure, which is called in Screen1.Initialise.
nico
April 16, 2025, 5:25pm
11
Issue resolved using your extension @TIMAI2 :
A get density block is available in many extensions, but I made this really for personal use for when I only needed to get the density of a screen.
Why do you need this? See this example of setting image size in the native listview. The image component image is sized in pixels, the listview image is sized in dpi. If you have the density you can easily set your listview images using pixel size. You may find the dpi sizing is also used in other places, especially in some image/graphical extension…
To get a fixed value, regardless of screen density, simply multiply the desired size by the screen density like this :
//with "size", the desired size in pixel
size * density1.density
I tested this method on several phones and got the same result for all of them.
Thanks anyway to @Kevinkun and @TIMAI2 for their help!
1 Like