iOS Question Tabstrip Indicator fit to width

Discussion in 'iOS Questions' started by Alexander Stolte, Apr 10, 2018.

  1. Alexander Stolte

    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:

    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to directly set the tabs widths. You can set the margins:
    Code:
    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.
     
  3. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    and what is if i dont have text?

    because, no matter what I enter as text length, it does not come on the left and right edge.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Change 80 to 0. The code I posted adds margins to each item.
     
  5. Alexander Stolte

    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.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Try to increase the leftRightMargin and see if you get better results.
     
  7. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    no matter what i set, the indicator in the Position = 0 is not on the left Edge, the max left is on the picture. Is this even possible?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    It is probably not possible.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice