Android Question What's is wrong with this Designer Script?


Well-Known Member
Licensed User
Hi all,

I have a problem with designer script for SetTopAndBottom command (Sample project Attached)

In my layout, there is pnlMain, pnlMain contains 3 panels, pnlTitle, pnlInput & pnlTbl.
pnlTbl contains 1 panel, pnlData.

On each panels, SetTopAndBottom command seem OK, but on pnlData is not OK.

Here is the sample on designer script :
pnlMain.Width = 100%x
pnlMain.Height = 100%y
pnlTitle.Width = pnlMain.Width

pnlTitle.Top = 0
pnlInput.SetTopAndBottom(pnlTitle.Bottom + 5dip,200dip)

pnlTbl.SetTopAndBottom(pnlInput.Bottom + 5dip,pnlMain.Bottom - 5dip)

pnlData.SetTopAndBottom(8dip,pnlTbl.Bottom -15dip)
'pnlData.Top = 8dip
'pnlData.Height = pnlTbl.Height -15dip
The last command pnlData.SetTopAndBottom(8dip,pnlTbl.Bottom -15dip) is supposed to set pnlData bottom 15dip above pnlTbl bottom, but it was not correct.

Anybody knows what is wrong with those codes?

Thanks in advance.



Well-Known Member
Licensed User
What about pnlTbl?

This panel is a child of pnMain, yet a command
pnlTbl.SetTopAndBottom(pnlInput.Bottom + 5dip,pnlMain.Bottom - 5dip) return a correct result.


Licensed User
That's because PlMain has the same size as the Parent activity.
SetTopAndBottom and SetLeftAndRight set their positions relative to its parent, so if its parent has a top and bottom of 10%y,90%y its has a 80%Y height, setting one of its childs to hava a botton equal to the parent's 90%y will make it offset by 10%y
That's why it is so easy and yet so tricky to use the scripts... everything can and should be relativized... with caution