Change the font size

vb1992

Well-Known Member
Licensed User
Longtime User
Is there a way to change the font size of the text
in a listview while the app is running, using a button
with the word "FONT +" - I can't seem to get it to change
real time, is there a update or refresh i need to do to see
the font size become bigger, thanks


B4X:
Dim Label1 As Label
Label1 = ListView1.TwoLinesLayout.SecondLabel
Label1.TextSize = 20
Label1.TextColor = Colors.Green


B4X:
Sub ButtonBiggerFontSize_Click
   Label1.textsize = Label1.TextSize + 3
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
Try calling the Labels invalidate method to force the label to redraw
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
This is the unsuccessful test


B4X:
'Activity module
Sub Process_Globals
 
End Sub

Sub Globals

   Dim lv As ListView
   Dim sb As SeekBar
   Dim lab As Label
   
End Sub

Sub Activity_Create(FirstTime As Boolean)

   Activity.Color=Colors.yellow

   lab.Initialize("lab")
   lv.Initialize("lv")
   
   Activity.AddView(lv,10%x,10%y,80%x,50%y)
   
   
   lv.Color=Colors.black
   
   
   ' attach label to listview
   '
   '
   
   lab = lv.SingleLineLayout.Label
   
   lab.TextSize = 10
   lv.AddSingleLine("Apples")
   
   lab.TextSize = 15
   lv.AddSingleLine("Pumpkins")
   
   lab.TextSize = 20
   lv.AddSingleLine("Corn")
   
   lab.Invalidate
   Lv.Invalidate
   activity.Invalidate
   
   '
   ' set up simple font size slider bar
   '
   sb.Initialize("sb")
   Activity.AddView(sb,10%x,80%y,80%x,10%y)
   sb.Max=22 'Max Font Size
   sb.Value=11
   
End Sub

 


Sub sb_ValueChanged (Value As Int, UserChanged As Boolean)
   
   ' Msgbox("You changed the value", "Changed")
    
   lab.Initialize("")
   lv.Initialize("")
   
   ' lets not go lower than a text size 5
   If Value > 6 Then
   
   lab = lv.SingleLineLayout.Label
   lab.TextSize = sb.Value
   lv.AddSingleLine("FontSizeChanged")

   
   lab.Invalidate
   Lv.Invalidate
   activity.Invalidate
   
   End If
   
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
I am curious to what is going on here with this ListView,
seems like two font sizes?

lv_3.png



listview tutorial
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
There is a separate label for each line which can have different styles.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
In the screenshot in post #6, there is a 'specialty', Erel added one item a single line item, then a two line item without bitmap and then a two line item with bitmap and so on.
You can have different text sizes for the one line and the two line setup.

Best regards.
 
Last edited:
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Thanks Klaus, works great using labels in Scrollview


i1=15
For i=0 To i1
Dim lbl As Label
lbl.Initialize("lbl1")
lbl.Color = Colors.Blue
lbl.Tag=i
lbl.TextSize = i + 10
lbl.Text = "Test1 line # "&i
scvTest1.Panel.AddView(lbl,0,i*lblHeight1,100%x,lblHeight)
scvTest1.Panel.Height = i1*lblHeight1
Next
 
Upvote 0
Top