Android Question Different widths in tabs of TabStrip

asales

Expert
Licensed User
Longtime User
I tried to change the widths of the 3 tabs in my tabstrip.
If I use the GetAllTabLabels function and set the sizes of all tabs to 33.3%x works fine, but I want to change to this sizes:
tab(0) = 30%x
tab(1) = 40%x
tab(2) = 30%x

I tested with the function TabWidth of the TabStripViewPagerExtendet class:
https://www.b4x.com/android/forum/threads/tabstripviewpagerextendet.88821/
but don't worked.
B4X:
Dim tse As TabStripViewPagerExtendet
tse.Initialize 'to Initialize the class

'Set the Tab width
tse.TabWidth(tsCadastro, 30%x, 0)
tse.TabWidth(tsCadastro, 40%x, 1)
tse.TabWidth(tsCadastro, 30%x, 2)
My goal is set the middle tab to a large size than the other tabs.

Thanks in advance for any tip.
 

asales

Expert
Licensed User
Longtime User
Where is the code?
Here:
B4X:
Sub Create_TabStrip
    tsCadastro.LoadLayout("Layout1", "PROFILE")
    tsCadastro.LoadLayout("Layout2", "COMPLEMENTARY")
    tsCadastro.LoadLayout("Layout3", "ADDITIONAL")

    For Each lbl As Label In GetAllTabLabels(tsCadastro)
        lbl.Padding = Array As Int(0, 0, 0, 0)
    Next
    
    Dim tse As TabStripViewPagerExtendet
    tse.Initialize 'to Initialize the class
    tse.TabWidth(tsCadastro, 30%x, 0)
    tse.TabWidth(tsCadastro, 40%x, 1)   'DON'T WORKS
    tse.TabWidth(tsCadastro, 30%x, 2)
    
    tsCadastro.ScrollTo(0, False)
End Sub

Code from TabStripViewPagerExtended:
B4X:
'Set the Tab width
Public Sub TabWidth(tabstrip As TabStrip,Width As Int,Position As Int)
    Dim i As Int
    For Each lbl As Label In GetAllTabLabels(tabstrip)
        If i = Position Then
            lbl.Width = Width
        End If
        i = i + 1
    Next
End Sub

And the result (the page 2 is not resize to 40%x):
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…