Android Question Spinners and extra large font size Scale

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

On my device (my development phone, Nexus 5x) it shows my UI correctly (it has the font size as normal), but on another persons phone (Samsung Galazy S7 edge) they have the font size set to Extra Large.

I am using the following code to make my objects in my layout display correctly regardless on the font size the user has set.

It seem to work for labels but I have some spinners in my layout and the following code doesn't seem to work.

Any ideas on what has gone wrong?

I am loading my layout before ResetUserFontScale(Activity) is called.


B4X:
Sub Process_Globals
   Dim access As Accessiblity
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
   ResetUserFontScale(Activity)
End Sub

Sub ResetUserFontScale(p As Panel)
   For Each v As View In p
     If v Is Panel Then
       ResetUserFontScale(v)
     Else If v Is Label Then
       Dim lbl As Label = v
       lbl.TextSize = lbl.TextSize / access.GetUserFontScale
     Else If v Is Spinner Then
       Dim s As Spinner = v
       s.TextSize = s.TextSize / access.GetUserFontScale
     End If
   Next
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
What I meant is that you should check the value of Spinner.TextSize and see whether it was changed or not.

The code above will not reach the spinner if the spinner was added to a TabHost or any other container other than Panel.

You can also set the text size directly:
B4X:
Spinner1.TextSize = Spinner1.TextSize / access.GetUserFontScale
 
Upvote 0
Top