iOS Question Tabstrip Indicator fit to width

Alexander Stolte

Expert
Licensed User
Longtime 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

B4X founder
Staff member
Licensed User
Longtime 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.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime 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.
 
Upvote 0
Top