U
unba1300
Guest
Hi,
In the Designer, I have five buttons, all the same width. But when I apply this code (as per the Designer Scripts Tutorial), the button in the middle does scale to the same width as the others.
The attached screen capture shows what it looks like at 480 x 800, scale = 1.
:sign0163:
In the Designer, I have five buttons, all the same width. But when I apply this code (as per the Designer Scripts Tutorial), the button in the middle does scale to the same width as the others.
B4X:
'All variants script
delta = ((100%x + 100%y) / (320dip + 480dip) - 1)
rate = 0.5 'value between 0 to 1.
scale = 1 + rate * delta
btnSpeech.Width = btnSpeech.Width * scale
btnSpeech.Height = btnSpeech.Height * scale
btnSpeech.SetLeftAndRight(0, btnSpeech.Width * scale)
btnSpeech.SetTopAndBottom(100%y - btnSpeech.Height * scale, 100%y)
btnMainPlay.Width = btnMainPlay.Width * scale
btnMainPlay.Height = btnMainPlay.Height * scale
btnMainPlay.SetLeftAndRight(0, btnMainPlay.Width * scale)
btnMainPlay.SetTopAndBottom(btnSpeech.Top - btnMainPlay.Height * scale, btnSpeech.Top)
btnMainSettings.Width = btnMainSettings.Width * scale
btnMainSettings.Height = btnMainSettings.Height * scale
btnMainSettings.SetLeftAndRight(100%x - btnMainSettings.Width * scale, 100%x)
btnMainSettings.SetTopAndBottom(100%y - btnMainSettings.Height * scale, 100%y)
btnMainMedia.Width = btnMainMedia.Width * scale
btnMainMedia.Height = btnMainMedia.Height * scale
btnMainMedia.SetLeftAndRight(100%x - btnMainMedia.Width * scale, 100%x)
btnMainMedia.SetTopAndBottom(btnMainSettings.Top - btnMainMedia.Height * scale, btnMainSettings.Top)
btnMainModify.Width = btnMainModify.Width * scale
btnMainModify.Height = btnMainModify.Height * scale
btnMainModify.HorizontalCenter = 50%x
btnMainModify.SetTopAndBottom(btnMainPlay.Top, btnSpeech.Top)
The attached screen capture shows what it looks like at 480 x 800, scale = 1.
:sign0163: