Set all the elements to a typeface

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,
I use loadfromassets to load a typeface and set the typefaces of my labels etc. to this.

Is there an easy way to set all the elements of my screen to this typeface?

Thanks

Peter
 
Yes:
Code: Copy
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   SetTypeface(Activity, Typeface.DEFAULT_BOLD)
End Sub

Sub SetTypeface(parent As Panel, t As Typeface)
   For Each v As View In parent
      If v Is Label Then
         Dim lbl As Label = v
         lbl.Typeface = t
      Else If v Is Panel Then
         SetTypeface(v, t)
      End If
   Next
End Sub
This code will set the typeface of all views that are subclasses of TextView: Button, EditText, Label, CheckBox and RadioButton.
 
Upvote 0
Back
Top