iOS Question Tabstrip Indicator fit to width

Alexander Stolte

Well-Known Member
Licensed User
Hello,

how can i to adjust the indicator length to the width?

in B4A i do it that way:

B4X:
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List
    Dim jo As JavaObject = tabstrip
    Dim r As Reflector
    r.Target = jo.GetField("tabStrip")
    Dim tc As Panel = r.GetField("tabsContainer")
    Dim res As List
    res.Initialize
    For Each v As View In tc
        If v Is Label Then res.Add(v)
    Next
    Return res
  
End Sub

For Each lbl As Label In Main.fun.GetAllTabLabels(ts_main)
        lbl.Width = Round(Activity.Width/3)
    Next
 

Erel

Administrator
Staff member
Licensed User
It is not possible to directly set the tabs widths. You can set the margins:
B4X:
Dim no As NativeObject = TabStrip1
Dim ButtonBarView As NativeObject = no.GetField("buttonBarView")
ButtonBarView.SetField("leftRightMargin", (GetDeviceLayoutValues.Width - 3 * 80) / 3 / 2)
You need to do it before you add items.
80 ~ average size of the text (just a guess)
It is divided by two because the margins are added twice to each item.
 

Alexander Stolte

Well-Known Member
Licensed User
hmm, same:
tabstrip.PNG

The indicator is on the first item left. The Tabstrip is left = 0 and rightedgedistance = 0 and the Horizontal Anchor = both.
But the indicator is not on the left edge.
 
Top