Android Question Confusion about GetDeviceLayoutValues.Scale

hung

Active Member
Licensed User
Longtime User
I am using a webview to draw html report then capture as bitmap to print on pdf.

I tried using px, rem, pt to set font size but the result are different in phone and tablet. For same font size, e.g. size=16px, phone draws smaller while tablet draws bigger.

I call GetDeviceLayoutValues.Scale, based on @Erel's example, should set font size like 30 / GetDeviceLayoutValues.Scale, then
1. phone has GetDeviceLayoutValues.Scale = 2.75, then 16/2.75 = 5.8 = 6
2. tablet has GetDeviceLayoutValues.Scale = 1.5, then 16/1.5 = 10.7 = 11

Phone draws even smaller and table draws even bigger. I tried 16 * 2.75 = 44 for phone, 16 *1.5 = 24 for tablet, both phone and table draw different font size.

So I am confused.

How could I draw consistent size of font in different devices?
 

hung

Active Member
Licensed User
Longtime User
I am using a webview to draw html report then capture as bitmap to print on pdf.

I tried using px, rem, pt to set font size but the result are different in phone and tablet. For same font size, e.g. size=16px, phone draws smaller while tablet draws bigger.

I call GetDeviceLayoutValues.Scale, based on @Erel's example, should set font size like 30 / GetDeviceLayoutValues.Scale, then
1. phone has GetDeviceLayoutValues.Scale = 2.75, then 16/2.75 = 5.8 = 6
2. tablet has GetDeviceLayoutValues.Scale = 1.5, then 16/1.5 = 10.7 = 11

Phone draws even smaller and table draws even bigger. I tried 16 * 2.75 = 44 for phone, 16 *1.5 = 24 for tablet, both phone and table draw different font size.

So I am confused.

How could I draw consistent size of font in different devices?
Or will the device resolution affect the display font size? Shouldn't be as I know.
 
Upvote 0

hung

Active Member
Licensed User
Longtime User
By occasional checking and reading in forum, luckily I found the following
- Found two different tablets showing different font sizes even both having same GetDeviceLayoutValues.Scale = 1.5
- The new tablet shows similar font size and phone, the original tablet shows large font
- Found @Erel's comment on #3 of https://www.b4x.com/android/forum/threads/gui-text-hight-problem.101766/#post-638990
- Found the original tablet drawing bigger font has set accessibility to Large font size while the phone has Default font size

So the solution becomes
- Ignore the GetDevicesLaoutValues.Scale. Set font size same for all devices
- Check all devices and make Android -> Accessibility to default for all

Then draw html report in Webview, capture as bitmap, and drawbitmap on PDF. All generated PDF with same/closer font size.
 
Upvote 0
Top