Android Question Autoscale device problem

SalentoFC

Member
Licensed User
Longtime 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

  • Screenshot_2014-12-15-05-56-24.png
    Screenshot_2014-12-15-05-56-24.png
    262.7 KB · Views: 161
  • IMG-20141228-WA0011.jpg
    IMG-20141228-WA0011.jpg
    164 KB · Views: 148
Last edited:

LucaMs

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

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

LucaMs

Expert
Licensed User
Longtime User
Settings - Accessibility - Large Text

Impostazioni - Accesso facilitato - Testo grande.

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

LucaMs

Expert
Licensed User
Longtime 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
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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".
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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"
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Probably you can set it using:

r.SetField("fontScale", "0.8", "java.lang.float")

(I have not tried)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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.
 
Upvote 0

SalentoFC

Member
Licensed User
Longtime 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?
 
Upvote 0

SalentoFC

Member
Licensed User
Longtime 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
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Upvote 0
Top