黑莓setMargin方法 [英] setMargin method in BlackBerry

查看:348
本文介绍了黑莓setMargin方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用setMargin()方法在我的黑莓应用程序。
任何一个可以请解释我的这种方法的细节。

I have to use setMargin() method in my blackberry application. can any one please explain me this method in detail.

setMargin(上,右,下,左)

setMargin(top,right,bottom,left)

请解释一下我详细我将如何使用上面4个参数显示在screen.May我的控制是它的一个非常简单的事情理解,但请帮助我,我真的很迷茫与右上左下parameters.May是我很misinter preting它并获得的不当控制在屏幕上显示

Please explain me in detail how will i use above 4 parameters to display my controls on the screen.May be its a very simple thing to understand but Please help me i am really very confused with the top right bottom left parameters.May be i am misinterpreting it and getting improper display of controls on screen

在此先感谢
Yogesh乔杜里

Thanks in advance Yogesh Chaudhari

推荐答案

默认情况下现场管理人员对齐的,从左至右,从上到下,但它有可能改变这一点。 setMargin是相对于场或在其上的对准的场中的对象。

By default field managers are aligned from left to right and from top to bottom but it is possible to change this. setMargin is relative to the field or to an object in the field on it's alignment.

Bitmap bitmap = EncodedImage.getEncodedImageResource("img/image.png").getBitmap();

HorizontalFieldManager hfm = new HorizontalFieldManager();
BitmapField a = new BitmapField(bitmap);
a.setMargin(20,0,0,10);
hfm.add(a);

BitmapField b = new BitmapField(bitmap);
b.setMargin(20,0,0,10);
hfm.add(b);

add(hfm);

在上面的例子中位图一被定位相对于场管理者HFM的顶部20个像素。例如。如果这是唯一的现场经理将其从屏幕顶部放置20 pixes。它是从HFM的开始的左侧定位10个像素。

In the above example bitmap 'a' is positioned 20 pixels relative to the top of the field manager hfm. E.g. if this is the only field manager it is positioned 20 pixes from the top of the screen. It is positioned 10 pixels from the left of the start of hfm.

位图​​B也被定位从HFM的顶部20像素,它是从右侧放置10个像素的位图A的大多数像素。这是因为我们是在一个(左到右)水平字段B相对于A的最右边的像素。

Bitmap 'b' is also positioned 20 pixels from the top of hfm and it is positioned 10 pixels from the right most pixel of bitmap 'a'. It's because we are in a (left to right) horizontal field that b is relative to a's right most pixel.

我们可以从右通过重新调整经理向左翻转这个例子。即。

We could flip this example from right to left by realigning the manager. I.e.

HorizontalFieldManager hfm = new HorizontalFieldManager(Field.FIELD_RIGHT);
...
a.setMargin(0,10,0,0); // positioned 10 pixels from the right

或类似的垂直管理

VerticalFieldManager vfm = new VerticalFieldManager();
...
a.setMargin(20,10,0,0);
...
b.setMargin(20,10,0,0);  
...

上面的'一'是对齐从VFM的顶部20像素和VFM左侧10像素。
B对准从VFM左侧10像素和20像素从A

The above 'a' is aligned 20 pixels from the top of vfm and 10 pixels from the left of vfm. 'b' is aligned 10 pixels from the left of vfm and 20 pixels from the bottom of 'a'

这篇关于黑莓setMargin方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆