减少BlackBerry的HorizontalFieldManager中2个按钮之间的空间 [英] Reduce space between 2 buttons in HorizontalFieldManager in BlackBerry
问题描述
在Blackberry中,我创建了一个水平字段管理器,并向其中添加了一些小尺寸的按钮,以在屏幕底部显示工具栏.但是我的问题是两个按钮之间的空间太大.
In Blackberry I have created a horizontal field manager and added some buttons of small size to it to display toolbar at the bottom of the screen. But my problem is there is too much space between the 2 buttons.
我必须缩小2个按钮之间的间距,以便我可以设法在屏幕底部至少放置6个按钮.我正在使用 BFmsg.setMargin(305,0,0,40)
语句.
I have to reduce this space between 2 buttons so that I can manage to place at least 6 buttons at the bottom of the screen. I am using the BFmsg.setMargin(305,0,0,40)
statement.
以下是我的代码:
BFcontacts = new ButtonField("Cnt")
{
protected void paint(Graphics graphics)
{
//Bitmap contactsbitmap = Bitmap.getBitmapResource("contacts.jpg");
//graphics.drawBitmap(0, 0, contactsbitmap.getWidth(), contactsbitmap.getHeight(), contactsbitmap, 0, 0);
graphics.setColor(Color.WHITE);
graphics.drawText("Cnt",0,0);
}
};
BFcontacts.setMargin(305,0,0,10);//vertical pos,0,0,horizontal pos
HFM.add(BFcontacts);
BFmsg = new ButtonField("Msgs")
{
protected void paint(Graphics graphics)
{
//Bitmap msgsbitmap = Bitmap.getBitmapResource("messages.jpg");
//graphics.drawBitmap(0, 0, msgsbitmap.getWidth(), msgsbitmap.getHeight(), msgsbitmap, 0, 0);
graphics.setColor(Color.WHITE);
graphics.drawText("Msgs",0,0);
}
};
BFmsg.setMargin(305,0,0,40);//vertical pos,0,0,horizontal pos : original
HFM.add(BFmsg);
add(HFM)
推荐答案
您尝试过使用自定义管理器吗?您可以按照您的选择放置内容
have u tried using custom manager u can place the contents as per ur choice like this
创建此类的对象并向其中添加项目
Create object of this class and add items to it
class BottomManager extends Manager
{
BottomManager()
{
super(Manager.NO_VERTICAL_SCROLL);
}
protected void sublayout(int width, int height)
{
Field field = getField(0);
layoutChild(field,Display.getWidth(), Display.getHeight());
setPositionChild(field,0,0);
field = getField(1);
layoutChild(field,Display.getWidth(), Display.getHeight());
setPositionChild(field,10+getField(0).getWidth(),0);
field = getField(2);
layoutChild(field,Display.getWidth(), Display.getHeight());
setPositionChild(field,10+getField(1).getWidth(),0);
field = getField(3);
layoutChild(field,Display.getWidth(), Display.getHeight());
setPositionChild(field,getField(2).getWidth()+10,0);
setExtent(Display.getWidth(), 40);
}
}
这篇关于减少BlackBerry的HorizontalFieldManager中2个按钮之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!