B4J Question JavaFX SegmentedButton - Buttons full width

TILogistic

Expert
Licensed User
Longtime User
An alternative for what you are looking for, you can use this:


 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Coming a bit late to the party, but in case someone's interested, this works fine:

B4X:
Private Sub FillSegmentedButtonsWidthToParent(SegmentedButton As SegmentedButton, itemCount As Int)

    ' Code based on https://www.b4x.com/android/forum/threads/how-to-style-and-set-tooltip-for-each-segmentedbutton-item.125635/#post-786548

    Dim i As Int
    Dim oneButtonWidth As Double = SegmentedButton.Parent.As(B4XView).Width / itemCount
    Dim JO As JavaObject = SegmentedButton
    For i = 0 To (itemCount - 1)
        Dim btn As B4XView = JO.RunMethodJO("getButtons", Null).RunMethod("get", Array(i))
        btn.Width = oneButtonWidth
    Next
End Sub
 
Upvote 0
Top