Android Question [Solved] How to change font size in views inside a TabStrip?

Sergio Castellari

Active Member
Licensed User
Situation:
a) I have in a B4XPage, a TabStrip with 5 Tabs
b) I need to resize the view fonts on each Tab
I did this but it doesn't work:
Class_Globals:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Private TabCobros As TabStrip
    Private B4XPageIndicator1 As B4XPageIndicator
    Private lblFecha As Label
    Private lblImporte As Label
    Private lblConcepto As Label
    Private lblCambio As Label
    Private lblDetalle As Label
    Private lblConta As Label
    Private Label14 As Label
    Private edtImporte As EditText
    Private B4XComboBox1 As B4XComboBox
    Private edtCambio As EditText
    Private edtDetalle As EditText
    Private lblCtaConta As Label
End Sub

Sub B4XPage_Created:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("pntMediosDeCobro")
    TabCobros.LoadLayout("tabMedioCobroEFE", "Efectivo")
    TabCobros.LoadLayout("tabMedioCobroCHE", "Cheque")
    TabCobros.LoadLayout("tabMedioCobroTAR", "Tarjeta")
    TabCobros.LoadLayout("tabMedioCobroDEP", "Depósito")
    TabCobros.LoadLayout("tabMedioCobroRET", "Retención")
    Sleep(0)
  'Ajusto tamaños de fuentes SIN importar el tamaño de fuente elegida por el Usuario...
    lblFecha.TextSize = lblFecha.TextSize/Main.pSysFontScale
    lblImporte.TextSize = lblImporte.TextSize/Main.pSysFontScale
    lblConcepto.TextSize = lblConcepto.TextSize/Main.pSysFontScale
    lblCambio.TextSize = lblCambio.TextSize/Main.pSysFontScale
    edtImporte.TextSize = edtImporte.TextSize/Main.pSysFontScale
    lblConta.TextSize = lblConta.TextSize/Main.pSysFontScale
    'B4XComboBox1.TextSize = B4XComboBox1.TextSize/Main.pSysFontScale
    edtCambio.TextSize = edtCambio.TextSize/Main.pSysFontScale
    edtDetalle.TextSize = edtDetalle.TextSize/Main.pSysFontScale
    lblCtaConta.TextSize = lblCtaConta.TextSize/Main.pSysFontScale
End Sub

c) I also can't manage to "change" the font size of the view "B4XComboBox"
Greetings
 

ilan

Expert
Licensed User
Longtime User
"B4XComboBox"
you can use CSBuilder.

like this:

B4X:
Sub addItemsToCombobox
    Dim l As List
    l.Initialize
    For i = 0 To 10
        l.Add(getFormatedText(Rnd(12,22),xui.Color_RGB(Rnd(0,256),Rnd(0,256),Rnd(0,256)),$"item ${i}"$))
    Next
    B4XComboBox1.SetItems(l)   
End Sub

Sub getFormatedText(fontsize As Int, fontcolor As Int, txt As String) As CSBuilder
    Dim cs As CSBuilder
    cs.Initialize.Color(fontcolor).Size(fontsize).Append(txt).PopAll
    Return cs
End Sub


1631880953720.png
 
Upvote 0

Sergio Castellari

Active Member
Licensed User
you can use CSBuilder.

like this:

B4X:
Sub addItemsToCombobox
    Dim l As List
    l.Initialize
    For i = 0 To 10
        l.Add(getFormatedText(Rnd(12,22),xui.Color_RGB(Rnd(0,256),Rnd(0,256),Rnd(0,256)),$"item ${i}"$))
    Next
    B4XComboBox1.SetItems(l)  
End Sub

Sub getFormatedText(fontsize As Int, fontcolor As Int, txt As String) As CSBuilder
    Dim cs As CSBuilder
    cs.Initialize.Color(fontcolor).Size(fontsize).Append(txt).PopAll
    Return cs
End Sub


View attachment 119213
wow !!! Thank you very much @ilan
This is more than what I needed, I see that in addition to the size you can change the color! Perfect!!
Would it be too much to ask if you could change the background color as well?

Big hug!!!
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
wow !!! Thank you very much @ilan
This is more than what I needed, I see that in addition to the size you can change the color! Perfect!!
Would it be too much to ask if you could change the background color as well?

Big hug!!!
You can try this:
B4X:
B4XComboBox1.cmbBox.DropdownBackgroundColor = xui.Color_Gray
B4XComboBox1.cmbBox.DropdownTextColor = xui.Color_White
B4XComboBox1.cmbBox.TextSize = 24
 
Upvote 0

Sergio Castellari

Active Member
Licensed User
You can try this:
B4X:
B4XComboBox1.cmbBox.DropdownBackgroundColor = xui.Color_Gray
B4XComboBox1.cmbBox.DropdownTextColor = xui.Color_White
B4XComboBox1.cmbBox.TextSize = 24
@Gabino A. de la Gala ...SPECTACULAR!!!

This is enough for me to "edit" the ComboBox.
I did not realize the property "cmbBox", from there you have many properties!
Thanks again to you and @ilan

See ya!!!
 
Upvote 0
Top