开发者

Setting padding in a blackberry app

开发者 https://www.devze.com 2023-02-25 10:09 出处:网络
I\'m trying to set the padding between various fields in a blackberry app. I can use setpadding method but this seems like overkill for what im trying to achieve. I just want to set a consistent spaci

I'm trying to set the padding between various fields in a blackberry app. I can use setpadding method but this seems like overkill for what im trying to achieve. I just want to set a consistent spacing around all fields. Is this possbible wi开发者_Go百科thout using setpadding? My fields are part of a verticalfield managers if that helps.

Thanks


If these are Fields you will be using frequently with the same amount of spacing the easiest solution would probably to extend the Field and in the constructor call a setMargin() on it.

public class SpacedLabelField extends LabelField {
    public SpacedLabelField(String text, long style) {
        super(text, style);
        setMargin(10, 10, 10, 10);
    }
}

I would recommend setMargin() because the Managers will take that information and give you an even spacing. For example, you have Field A with a bottom margin of 10 and Field B with a top margin of 10. If you stack A on top of B you will end up with a spacing between them of 10 rather than 20 (at least this has been my observed behavior in 5.0).

At any rate, now rather than having to create your Field and then call setMargin() on each, you only have to call your class and it will already be formatted for you.

Alternatively you could create your own Manager and in the sublayout() call implement a spacing between the Field when you are laying out and positioning them.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号