Hello,
I am trying to create a layout using the designer and need some help with the code in the designer.
First of all I am trying to display 12 buttons on the screen and spacing them all apart evenly.
I need to have 3 buttons per line and I am trying to place them in a panel.
I have changed the parent for each of the buttons to be in the panel rather then the Activity.
When the panel is re-sized I need the buttons to move closer etc.
Here is what I am trying to do:
The layout on the left is when it's full screen, and the layout on the right is when I re-size the panel.
The size of the buttons should stay the same size just need them to move closer to each other when the panel is re-sized.
I can't seem to work out how to space the buttons apart and then when I re-size the panel it make it follow.
The panel is called 'Keys' and each of the buttons are just called Key1, Key2 etc..
Here is what I have done so far:
When I run the above code it looks like this:
Then when I change the size of my panel to:
The layout then looks like the following:
I am guessing I am doing something wrong but I can't work out how to space them correctly.
Anyone able to help me out spacing the buttons evenly in the panel no matter what size the panel is ?
I am trying to create a layout using the designer and need some help with the code in the designer.
First of all I am trying to display 12 buttons on the screen and spacing them all apart evenly.
I need to have 3 buttons per line and I am trying to place them in a panel.
I have changed the parent for each of the buttons to be in the panel rather then the Activity.
When the panel is re-sized I need the buttons to move closer etc.
Here is what I am trying to do:
The layout on the left is when it's full screen, and the layout on the right is when I re-size the panel.
The size of the buttons should stay the same size just need them to move closer to each other when the panel is re-sized.
I can't seem to work out how to space the buttons apart and then when I re-size the panel it make it follow.
The panel is called 'Keys' and each of the buttons are just called Key1, Key2 etc..
Here is what I have done so far:
B4X:
Keys.Width = 100%x
Keys.Height = 100%y
Keys.Top = 0dip
Keys.Left = 0dip
Key1.Top = 100%y / 4
Key2.Top = 100%y / 4
Key3.Top = 100%y / 4
Key4.Top = 100%y / 4 + 20%y
Key5.Top = 100%y / 4 + 20%y
Key6.Top = 100%y / 4 + 20%y
Key7.Top = 100%y / 4 + 40%y
Key8.Top = 100%y / 4 + 40%y
Key9.Top = 100%y / 4 + 40%y
Key10.Top = 100%y / 4 + 60%y
Key11.Top = 100%y / 4 + 60%y
Key12.Top = 100%y / 4 + 60%y
Key1.Left = (Keys.HorizontalCenter / 3) - Key1.Width
Key2.Left = Keys.HorizontalCenter - Key2.Width
Key3.Left = (Keys.HorizontalCenter / 3) + Key3.Width + 100dip
Key4.Left = (Keys.HorizontalCenter / 3) - Key4.Width
Key5.Left = Keys.HorizontalCenter - Key5.Width
Key6.Left = (Keys.HorizontalCenter / 3) + Key6.Width + 100dip
Key7.Left = (Keys.HorizontalCenter / 3) - Key7.Width
Key8.Left = Keys.HorizontalCenter - Key8.Width
Key9.Left = (Keys.HorizontalCenter / 3) + Key9.Width + 100dip
Key10.Left = (Keys.HorizontalCenter / 3) - Key10.Width
Key11.Left = Keys.HorizontalCenter - Key11.Width
Key12.Left = (Keys.HorizontalCenter / 3) + Key12.Width + 100dip
When I run the above code it looks like this:
Then when I change the size of my panel to:
B4X:
Keys.Width = 100%x
Keys.Height = 100%y
Keys.Top = 0dip
Keys.Left = 0dip
The layout then looks like the following:
I am guessing I am doing something wrong but I can't work out how to space them correctly.
Anyone able to help me out spacing the buttons evenly in the panel no matter what size the panel is ?