Android Question ListView not detected for fontscaling

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I use the following to reverse big fonts of Android setting:
B4X:
Public Sub ResetUserFontScale(p As Panel)
    Dim Factor As Double
    
    If(Starter.ScreenWidth>=1200) Then
        Factor=1.1
    Else
        Factor=1
    End If
    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 * Factor) / Starter.access.GetUserFontScale
            'Log("LBL is AANWEZIG")
        Else If v Is Spinner Then
            Dim s As Spinner = v
            s.TextSize = (s.TextSize * Factor) / Starter.access.GetUserFontScale
            'Log("SPIN is AANWEZIG")
        Else If v Is ListView Then
            Dim lv As ListView = v
            lv.SingleLineLayout.Label.TextSize = (lv.SingleLineLayout.Label.TextSize * Factor) / Starter.Access.GetUserFontScale
            lv.TwoLinesLayout.Label.TextSize = (lv.TwoLinesLayout.Label.TextSize * Factor) / Starter.Access.GetUserFontScale
            lv.TwoLinesLayout.SecondLabel.TextSize = (lv.TwoLinesLayout.SecondLabel.TextSize * Factor) / Starter.Access.GetUserFontScale
            lv.TwoLinesAndBitmap.Label.TextSize = (lv.TwoLinesAndBitmap.Label.TextSize * Factor) / Starter.Access.GetUserFontScale
            lv.TwoLinesAndBitmap.SecondLabel.TextSize = (lv.TwoLinesAndBitmap.SecondLabel.TextSize * Factor) / Starter.Access.GetUserFontScale
            Log("LV is AANWEZIG")
        End If
    Next
End Sub

It works fine for Labels, but not for ListView. The ListView is not detected within the panel.

What is wrong with this? Can somebody help me?

BR, André
 

stevel05

Expert
Licensed User
Longtime User
Check to make sure that the listview is actually in the panel and not on the activity in the designer (assuming you've used the designer)

Edit:This was an initial thought, but I'll leave it here just in case, see the next post.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you add:

B4X:
Log(v Is Panel)
Log(V Is Spinner)
Log(V Is ListView)

you will see that the listview returns true to the V Is Panel check. I guess that it is a child of Panel in the library so responds as such.

You can put the test for ListView before the test for panel and it should work as expected.
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
If you add:

B4X:
Log(v Is Panel)
Log(V Is Spinner)
Log(V Is ListView)

you will see that the listview returns true to the V Is Panel check. I guess that it is a child of Panel in the library so responds as such.

You can put the test for ListView before the test for panel and it should work as expected.

Thanks. I will try this tomorrow.

BR, André
 
Upvote 0
Top