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
New Contributor
naleen
Posts: 5
Registered: ‎11-24-2010
My Device: 9500
Accepted Solution

setMargin Problem !

 

Hi,all
In my project, i encountered a problem:
i found that  between the images ,setMargin() do not work!
here's  my test codes.
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;

public class BB extends UiApplication {

	public static void main(String[] args) {
		BB app = new BB();
		app.enterEventDispatcher();
	}

	public BB() {
		pushScreen(new BBScreen());
	}

	class BBScreen extends MainScreen {

		BBScreen() {
			setTitle("TEST");
			HorizontalFieldManager hfm = new HorizontalFieldManager(
					USE_ALL_WIDTH);
			BitmapField bmf1;
			BitmapField bmf2;
			BitmapField bmf3;

			bmf1 = new BitmapField(Bitmap.getBitmapResource("loading.png"));
			bmf2 = new BitmapField(Bitmap.getBitmapResource("loading.png"));
			bmf3 = new BitmapField(Bitmap.getBitmapResource("loading.png"));

			bmf1.setMargin(50, 20, 50, 20);
			bmf2.setMargin(50, 20, 50, 20);
			bmf3.setMargin(50, 20, 50, 20);

			hfm.add(bmf1);
			hfm.add(bmf2);
			hfm.add(bmf3);

			add(hfm);
			add(new SeparatorField());
		}
	}
}

 

 and the results is
1.PNG
i searched in the past posts,but nothing found.
because when i  focus to the image ,there's a border,so i can't use setPadding().

 

very strange problem,can anyone help me?

Please use plain text.
New Contributor
naleen
Posts: 5
Registered: ‎11-24-2010
My Device: 9500

Re: setMargin Problem !

The distance between images should be 40 ,but  it  is  20.

Please use plain text.
Developer
paulkayuk
Posts: 133
Registered: ‎04-30-2010
My Device: Curve 8520

Re: setMargin Problem !

That is working as designed, but it caught me out too initially. The Managers maintain the margin between Fields as a single value equal to the greater of the 2 margins set for adjacent fields, in your case 20. NOT as the sum of the 2 margins between 2 adjacent fields.
Please use plain text.
Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.634 Dev OS, Z30 (STA100-5)-10.3.1.634 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: setMargin Problem !

That is correct. If only I could find the resource. There should be some article in the KB that shows how a field is arranged. It shows Content, Padding, Border, and Margin.

 

They have something like this when you look at the HorizontalFieldManager documentation for API 6.0 (scroll down if you don't see it).

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: setMargin Problem !

It has finally been documented in the 6.0 API documentation. Check the entries for HorizontalFieldManager or VerticalFieldManager, for example.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
New Contributor
naleen
Posts: 5
Registered: ‎11-24-2010
My Device: 9500

Re: setMargin Problem !

hi, rcmaniac25, Thanks for API 6.0 Docs!

 

 

Please use plain text.
New Contributor
naleen
Posts: 5
Registered: ‎11-24-2010
My Device: 9500

Re: setMargin Problem !

This figure shows all.

1.PNG

 

THX all!

I should seriously look at API 6.0.

Please use plain text.