Android Question dynamic position (button not set to it own place)

qey

Member
Hello everyone, I have this five buttons (Image 1). But user have option to disable the buttons. Image 2 is the example when user disable the Invoice and Payment button. So i want the position of the button more dynamic not set to it own place, for example the Booking button in Image 2 will re-positioning it automatically besides the POD button. Any one can help ? Thank you

Image 1:
1660706250267.png

Image 2:
1660706163784.png
 
Solution
1660724542730.png

B4X:
    Label3.Visible = False
    
    Dim VisibleCounter As Int = 0
    Dim GapBetween As Float = 10dip 'The gap between the labels
    For i = 0 To Root.NumberOfViews -1 'Put your buttons inside a panel, so you can loop through
        
        Dim xlbl As B4XView = Root.GetView(i)
        If xlbl.Visible = True Then  'If the label visible
            xlbl.Left = ((xlbl.Width + GapBetween)*VisibleCounter) + GapBetween 'Set the left position of the label + an extra gap, so that the button on the left does not stick to the corner
            VisibleCounter = VisibleCounter +1 'Count +1
        End If
        
    Next

Alexander Stolte

Expert
Licensed User
Longtime User
1660724542730.png

B4X:
    Label3.Visible = False
    
    Dim VisibleCounter As Int = 0
    Dim GapBetween As Float = 10dip 'The gap between the labels
    For i = 0 To Root.NumberOfViews -1 'Put your buttons inside a panel, so you can loop through
        
        Dim xlbl As B4XView = Root.GetView(i)
        If xlbl.Visible = True Then  'If the label visible
            xlbl.Left = ((xlbl.Width + GapBetween)*VisibleCounter) + GapBetween 'Set the left position of the label + an extra gap, so that the button on the left does not stick to the corner
            VisibleCounter = VisibleCounter +1 'Count +1
        End If
        
    Next
 

Attachments

  • Example Dynamic Buttons.zip
    4.5 KB · Views: 150
Upvote 0
Solution

qey

Member
View attachment 132641
B4X:
    Label3.Visible = False
   
    Dim VisibleCounter As Int = 0
    Dim GapBetween As Float = 10dip 'The gap between the labels
    For i = 0 To Root.NumberOfViews -1 'Put your buttons inside a panel, so you can loop through
       
        Dim xlbl As B4XView = Root.GetView(i)
        If xlbl.Visible = True Then  'If the label visible
            xlbl.Left = ((xlbl.Width + GapBetween)*VisibleCounter) + GapBetween 'Set the left position of the label + an extra gap, so that the button on the left does not stick to the corner
            VisibleCounter = VisibleCounter +1 'Count +1
        End If
       
    Next
Thank you so much for this @Alexander Stolte , i will test it in my apps.
 
Upvote 0
Top