Android Question Characters out of their frame

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
In my app, letters are normally placed in labels and Edit Text. But if from the device I modify the font size, they exceed the label frame and or the text frame.
What is the way when programming so that the numbers and letters do not come out of their container when the font is enlarged from the smartphone.
Look at the attach files.
Thank you
 

Attachments

  • Screenshot_20240310_090054.jpg
    Screenshot_20240310_090054.jpg
    52 KB · Views: 27
  • Screenshot_20240310_090409.jpg
    Screenshot_20240310_090409.jpg
    66.6 KB · Views: 28

Alessandro71

Well-Known Member
Licensed User
Longtime User
I use this code to reset font scale, so app is not affected by user settings

B4X:
'reset font size to 1.0
'override user setting in control panel
Sub Process_Globals
   Public access As Accessiblity
End Sub

'reset all fonts in a panel
Sub ResetUserFontScale(p As Panel)            'ignore
    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
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
No, it doesn't work.
I loaded the Accessibility library. Then the code below, but the characters continue to grow and exceed their container if I increase the size of the font on the smartphone.

B4X:
Sub Process_Globals
    Public access As Accessiblity
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ResetUserFontScale(Activity)
    Activity.LoadLayout("Params")
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
 
Upvote 0
Top