01-31-2011 07:55 PM
Hey all. Trying my hand at PlayBook development. Is there any way that i can add a 10 or so pixel
padding to buttons that i am laying out?
This is how ive been doing it(the manual way with hard coded X and Y cords)
myBtn.x = 50; myOtherBtb.x = 200;
Let me know if there is a better way. Thanks for your time!
01-31-2011 09:36 PM
welcome to the forums! there are two way that i know of to add padding to an object or button. the first way is the QNX API way by using the Container class. it uses its own spacing and positioning so you dont have to hard code a lot of things. the downside is that it gives you little control over placement and you are soemtimes forced to do work arounds in some situations. here is more information about containers:
the second way to do it is to create a variable to store the amount of padding so you dont have to retype the number everytime. that way it stays consistent and if you change it in one place it will be changed in all the other places.
so something like this:
private const PADDING:int = 10; (...) myBtn.x = 50; myOtherBtn.x = myBtn.x + myBtn.width + PADDING; myOtherOtherBtn.x = myOtherBtn.x + myOtherBtn.width + PADDING;
that being said i use the second method because im not too big of a fan of containers. i certainly recommend you try both ways before making any final decisions. some people do like containers and some people dont. in the end its up to you. there is no set way to add a padding except for you finding a way to do it by manipulation. hope that sheds some light. good luck!
01-31-2011 10:09 PM