it's because i already made the app with the right size of texts... so i don't want the user to zoom even more... the app became unusable. Or in some cases i used labels to put icons with MaterialDesign or FontAwesome... so that text zooms so much that is cutted out from the hitbox of the object.
Is there way to prevent from Android, or i've to call that function in all the pages? my problem is that is use a lot of objects from libraries or classes...
Ok Erel, thanks.
I'm trying to implement this function.
However i'm experimenting some issues.
The code i use is this:
B4X:
Sub ResetUserFontScale(p As Panel)
For Each v As B4XView In p
If v Is Panel Then
ResetUserFontScale(v)
Else If v Is Label Then
Dim lbl As Label = v
'Log(lbl.Text)
'Log(access.GetUserFontScale)
'Log(GetType(v))
lbl.TextSize = lbl.TextSize / access.GetUserFontScale
Else if v Is AutoTextSizeLabel Then
Dim albl As AutoTextSizeLabel = v
albl.BaseLabel.TextSize = 0
End If
Next
End Sub
in the layout there are some AutoTextSizeLabels... but seems that them are classfied as "Label" and then the method "TextSize" does not do anything because it does not exists for them, but you should do: AutoTextSizeLabel1.BaseLabel.TextSize but i can't do this becuase i'm not able to distinguish between actual Labels and AutoTextSizeLabels.
And after you do everything then the user will not be able to read the text as it is too small for the user. The user chose to increase the text size for a reason.
What about if you try to involve the Tag property. Something like this works, but I have not applied it to accessibility to see if it works. In designer put 0 in the regular label tag and 1 in the AutoTextSizeLabel tag
B4X:
Sub ResetUserFontScale(p As Panel)
For Each v As B4XView In p.GetAllViewsRecursive
If v Is Panel Then
v.Color=xui.Color_Magenta
Else if v Is Button Then
Dim b As Button=v
b.Color=xui.Color_Green
b.Text="Click me"
b.TextSize=40
Else if v Is Label Then
Dim lbl As Label = v
If lbl.Tag ="0" Then 'in designer put 0 in the regular label tag and 1 in the AutoTextSizeLabel tag
lbl.Text= "I am just a label"
lbl.Color=xui.Color_Yellow
lbl.TextSize= 30
Else if lbl.Tag ="1" Then
lbl.Text= "I am AutoTextSizeLabel"
lbl.Color=xui.Color_Blue
lbl.TextSize=10
End If
End If
Next
End Sub
And after you do everything then the user will not be able to read the text as it is too small for the user. The user chose to increase the text size for a reason.
As I said... the app is already made keeping in mind that is targeted to old people, so the texts and icons are already big.
If someone has the zoom option enabled it looks like an elephant in a drawer .
Apart for the joke.. actually in some cases the texts and icons became so big that them are cutted out.. so they are unreadable anyway. And making the default text smaller became problematic for the ones that does not have the zoom enabled maybe.
What about if you try to involve the Tag property. Something like this works, but I have not applied it to accessibility to see if it works. In designer put 0 in the regular label tag and 1 in the AutoTextSizeLabel tag
B4X:
Sub ResetUserFontScale(p As Panel)
For Each v As B4XView In p.GetAllViewsRecursive
If v Is Panel Then
v.Color=xui.Color_Magenta
Else if v Is Button Then
Dim b As Button=v
b.Color=xui.Color_Green
b.Text="Click me"
b.TextSize=40
Else if v Is Label Then
Dim lbl As Label = v
If lbl.Tag ="0" Then 'in designer put 0 in the regular label tag and 1 in the AutoTextSizeLabel tag
lbl.Text= "I am just a label"
lbl.Color=xui.Color_Yellow
lbl.TextSize= 30
Else if lbl.Tag ="1" Then
lbl.Text= "I am AutoTextSizeLabel"
lbl.Color=xui.Color_Blue
lbl.TextSize=10
End If
End If
Next
End Sub
What about if you try to involve the Tag property. Something like this works, but I have not applied it to accessibility to see if it works. In designer put 0 in the regular label tag and 1 in the AutoTextSizeLabel tag
B4X:
Sub ResetUserFontScale(p As Panel)
For Each v As B4XView In p.GetAllViewsRecursive
If v Is Panel Then
v.Color=xui.Color_Magenta
Else if v Is Button Then
Dim b As Button=v
b.Color=xui.Color_Green
b.Text="Click me"
b.TextSize=40
Else if v Is Label Then
Dim lbl As Label = v
If lbl.Tag ="0" Then 'in designer put 0 in the regular label tag and 1 in the AutoTextSizeLabel tag
lbl.Text= "I am just a label"
lbl.Color=xui.Color_Yellow
lbl.TextSize= 30
Else if lbl.Tag ="1" Then
lbl.Text= "I am AutoTextSizeLabel"
lbl.Color=xui.Color_Blue
lbl.TextSize=10
End If
End If
Next
End Sub
Before trying this solution I checked if I was already using the .Tag property for something else.. and I was.
So in the end i modified the AutoTextSizeLabel class itself to add the "Ingore User Font Scale" property directly there.
Hello i am facing a weird problem with system font size my app display a website in a webview everything is working correctly if the system font is set to normal if it is set to anything other than normal then stuff will go wrong normal font large font at first i thought the...
www.b4x.com
B4X:
#if Java
import android.content.*;
import android.content.res.*;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
final Configuration override = new Configuration(newBase.getResources().getConfiguration());
override.fontScale = 0.9f;
applyOverrideConfiguration(override);
BA.Log("attachBaseContext");
}
#End If
Maybe this code can work for you. If you are using B4xpages, add it to the Main page.