The other day I received a report (along with screenshots) from a user saying that certain labels on his Galaxy S3 were truncated or simply did not show up correctly. I found this rather odd since my developer-phone is also a Galaxy S3 and of course I had made sure that everything (my layouts) looked OK, not only on my S3, but also in other resolutions.
First I thought the user might have installed a custom-ROM with different system-fonts but then it struck me the user could have enlarged the system-fonts in the display-settings and indeed he had.
In this specific case, I was able to fix it easily by enlarging the labels but I am wondering if the designer-script and the auto-scale features take into consideration these situations when a user enlarge the system font-size? Any ideas?
If not, is it possible to get the size of the system-font in use? Of course I don't want to override this because if a user has deliberately increased the font-size, there is surely a good reason for it (sight-problems etc) and perhaps we developers should foresee that there can be problems with layouts in these situations and we should adapt our code/design somehow although this might not always be possible (short of screen-space) and in these cases we could launch a messagebox or similar informing the user there might be layout-issues.
I just tested this with one of my apps that uses Auto Scale by changing the font on my Droid 4 from Normal to Huge. When I ran my app, the text was too large and truncated. So my guess is that the Auto Scale and Designer Script does not take it into consideration.
I would also like to know how to get this information.
Yes, you can create a simple loop that removes the user scale. However the question is whether you should do it as this is the user decision to increase the font size.
Yes, you can create a simple loop that removes the user scale. However the question is whether you should do it as this is the user decision to increase the font size.
Because of this thread, I'm putting some code at the start of Activity Create to check font scale size and if it's not 1, giving the user the option of quitting or letting the app scale it back to 1 and then setting it back when he exits the app.
What is the "simple loop that removes the user scale."
*Edit: Never mind. I finally found your post on the subject and found that it is not changing the font size scale but the text size assigned to all views in the app with text, which I don't think will work for me.
Yes, you can create a simple loop that removes the user scale. However the question is whether you should do it as this is the user decision to increase the font size.
This code will take care of Labels, EditText, Buttons, CheckBoxes, RadioBoxes and Spinners:
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
thank you erel
but my app just freeze and closing when i use your code
so i am just informing now on the start of my app that it recommendet to change the font to normal
B4X:
Sub ResetUserFontScale(p As Panel)
Try
Dim fscale As Double
fscale = NumberFormat(access.GetUserFontScale,0,2)
If fscale <> 1 Then
Msgbox("על מנת שהאפליקציה תעבוד כראוי מומלץ לשנות את גודל הפונט בהגדרות של המכשיר שלכם לרגיל" ,"אזהרה")
End If
Catch
DateTime.DateFormat = "dd/MM/yyyy"
loglist.Add ("menu | fontscale " & DateTime.Date(DateTime.Now))
End Try
End Sub
Sub ResetUserFontScale'(p As Panel)
Dim fscale As Double
fscale = access.GetUserFontScale
For Each v As View In activity
If v Is Label Then
Dim lbl As Label = v
lbl.TextSize = NumberFormat2(lbl.TextSize / fscale,1,0,0,False)
Else If v Is Button Then
Dim s As Button = v
s.TextSize = NumberFormat2(s.TextSize / fscale,1,0,0,False)
End If
Next
' DoEvents
End Sub
the problem is that views that are in panels are not checked only views in my activity
so i did like this and it works
B4X:
Dim fscale As Double
fscale = access.GetUserFontScale
For Each v As View In pbottom '(pbottom is a panel)
If v Is Label Then
Dim lbl As Label = v
lbl.TextSize = NumberFormat2(lbl.TextSize / fscale,1,0,0,False)
Else If v Is Button Then
Dim s As Button = v
s.TextSize = NumberFormat2(s.TextSize / fscale,1,0,0,False)
End If
Next
'DoEvents
its strange that if i run for each .. in activity he only checked vies that are in my activity but not in panels
do i really have to search each panel for his views?
Dim fscale As Double
fscale = access.GetUserFontScale
If fscale > 1 Then
For Each v As View In activity.GetAllViewsRecursive
If v Is Label Then
Dim lbl As Label = v
lbl.TextSize = NumberFormat2(lbl.TextSize / fscale,1,0,0,False)
Else If v Is Button Then
Dim s As Button = v
s.TextSize = NumberFormat2(s.TextSize / fscale,1,0,0,False)
End If
Next
End If
now if the user set the font bigger the normal then it change all vies textbox to normal
one thing it doesnot do, the listviews items, clv items, msgbox,.. are still big
how can i control them?
Ive tested it in many activities with differents views.
And it make all to freeze, may be because its a recursive call?
attached goes the ofensive .bal
The code in the Activity create is