Android Question Autoscale device problem

SalentoFC

Member
Licensed User
Hi guys,
I'd like to know why on some devices the autoscale of txtbox is ok (ex s3 and s4) but on phones of my parents (note II and Vodafone cell) resolution of txtbox is not ok.
I'll attach 2 same screenshots (first ok on my s3 and second not ok on note 2)
naturally relatives to 1 posto.
See both pictures and notate differences.
Tks everybody.

If you like watching my app is avaible on google play store as name of "Storic Memory Game arma carabinieri" and download it.
tks for helping
 

Attachments

Last edited:

LucaMs

Expert
Licensed User
It could also be a problem of device settings.

I never modify them, but I remember that you can select the "font size".
 

LucaMs

Expert
Licensed User
Settings - Accessibility - Large Text

Impostazioni - Accesso facilitato - Testo grande.

We can search on site how to get this info by code ;)
 

LucaMs

Expert
Licensed User
Found this (Web):

if Large Text is set, android changes the font scale , so you can detect using
B4X:
Configuration c = getResources().getConfiguration();

float scale = c.fontScale;
if scale is greater than 1 then it is large text.


now we need to "translate" it to b4a!
Probably a JavaObject can be enough
 

LucaMs

Expert
Licensed User
B4X:
Sub LargeTextSet As Boolean
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod("getResources")
    r.Target = r.RunMethod("getConfiguration")
    Dim Sc As Float = r.GetField("fontScale")
    Return (Sc > 1)
End Sub
This should work (wow, my first code with reflection, if I remember correctly!).

So if the function returns True you will have to adapt the font size.
 

LucaMs

Expert
Licensed User
I don't know if you can change that user setting (and maybe it would not be correct, unless you can then set it as it was).

Unfortunately, I see no other possibility that multiply all textsize to a decimal value less than 1, if that setting is set to "Large Text".
 

LucaMs

Expert
Licensed User
Now I search if you can set that option by code.

Otherwise, you can check the setting and possibly put a message like:

"for better viewing, please uncheck ... etc"
 

LucaMs

Expert
Licensed User
from web:

You can't change a default font size. You can define a theme, and define a font size in your theme. You can read about defining themes and styles in the android developer reference documentation.
----
You can change font size, style etc in your application, but not for whole device. To do that i guess you need to root your phone and provide custom fonts with specified font size in it.
 

SalentoFC

Member
Licensed User
Però potrei mettere un avviso iniziale dove avviso l'utente di controllare il settaggio della grandezza del carattere o è esteticamente brutto a vedersi?
-------------------------------------
Can I put an advise at start where I indicate to the user to control the font size of default device or is a bad thing to do?
 

SalentoFC

Member
Licensed User
Non l'avevo letto perdonami
Anche se mi sembra strano non poter settare questa cosa da codice

Sorry, I didn't read it.
Seems strange is.not possible to set it from code
 

LucaMs

Expert
Licensed User
Top