Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

How to give padding margins to the elemnts addded to custom manager layout?

We have created our own custom layout manager. We are using this layout manger to add fields to screen. 

 

We add fields to this manager and then add this manager to the mainscreen. This manager have background image.

 

How can i specify the margin and padding for the fields added to the manager?

 

Thanks

Developer
Posts: 101
Registered: ‎07-20-2009
My Device: Not Specified

Re: How to give padding margins to the elemnts addded to custom manager layout?

You can use setPadding(int top, int left, int bottom, int right) and setMargin(int top, int left, int bottom, int right) method for any field.

Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: How to give padding margins to the elemnts addded to custom manager layout?

setPadding() is only available for 4.6 API's ..........it is better if you use setMargin() , it works for 4.2 or more API's

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to give padding margins to the elemnts addded to custom manager layout?

I beleive setPadding is available in 4.2.

 

Why is setMargins better?

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to give padding margins to the elemnts addded to custom manager layout?

Since you have a custom layout manager anyway, just count those margins and paddings (and borders, if necessary) in your calculations.  You are no doubt using layoutChild and setPositionChild inside your sublayout - factor your margins and paddings in the values you pass to those methods.

 

It is tedious, but you'll have full control.  If you use RIM's components as managed fields, set their paddings as it's the only way to make them paint the way you want.  Don't use setMargins - you are controlling that surrounding area anyway, so just don't place anything there.

 

Another point to consider: unless you really want to support 4.2, take a look at net.rim.device.api.ui.decor package.

 

Good luck,

Arkady.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: How to give padding margins to the elemnts addded to custom manager layout?

Hi Peter,

 

Iam not good like you in blackberry...............

 

However, am working on a project & in that project my senior used setPadding() method , but when i compiled the code with BB JDE 4.2 it gave me a compilation errror saying...........setPadding() method is not found.............When I looked into blackberry API reference then i didn't find any method setPadding().............

 

Then I replaced setPadding() method with setMargin() & it started working fine..................

 

That's why I said that it is better to use setMargin() as it will make application compatible for lower OS devices..............

 

After compiling my code with some more versions of JDE ,  I found out that setPadding() is available only for equal or more than 4.6 API's........................

Developer
Posts: 103
Registered: ‎12-12-2011
My Device: Developer
My Carrier: Robosoft

Re: How to give padding margins to the elemnts addded to custom manager layout?

A small observation with Decor package, we can't set both border and background for a  manager as expected. For ex: if we want to have a rounded border and background of some color other than white, then background color would appear only for the area where fields inside the manager are placed, in a rectangular form. It is not applied for the corners.

I could not find the perfect reason for this behavior and had to go for paint() method for getting rounded border for the manager. If someone can throw light on this, it would be a great help. Thanks in advance.