05-12-2010 05:32 AM
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?
05-12-2010 05:37 AM
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.
05-12-2010 11:45 AM
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.
05-12-2010 01:02 PM
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........................
07-19-2012 01:36 AM
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.