FieldManager 中的中心 ButtonField
我想在水平字段管理器中将按钮字段居中
我尝试了该代码:
HorizontalFieldManager ButM = new HorizontalFieldManager(Field.FIELD_HCENTER|USE_ALL_WIDTH)
{
public void paint(Graphics graphics)
{
graphics.setBackgroundColor(0x00000000);
graphics.clear();
super.paint(graphics);
}
};
ButtonField Order = new ButtonField("Tri",Field.FIELD_HCENTER|ButtonField.CONSUME_CLICK);
但是按钮字段没有居中,我做错了什么吗?
编辑 :
我使用以下代码解决了这个问题:
HorizontalFieldManager ButM = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER|USE_ALL_WIDTH)
{
public void paint(Graphics graphics)
{
graphics.setBackgroundColor(0x00000000);
graphics.clear();
super.paint(graphics);
}
};
ButtonField Order = new ButtonField("Tri",DrawStyle.HCENTER|ButtonField.CONSUME_CLICK);
Order.setMargin(0,0,0,(Display.getWidth()/2)-30);
I wanna center a buttonField in a HorizontalFieldManager
i tried that code :
HorizontalFieldManager ButM = new HorizontalFieldManager(Field.FIELD_HCENTER|USE_ALL_WIDTH)
{
public void paint(Graphics graphics)
{
graphics.setBackgroundColor(0x00000000);
graphics.clear();
super.paint(graphics);
}
};
ButtonField Order = new ButtonField("Tri",Field.FIELD_HCENTER|ButtonField.CONSUME_CLICK);
But the ButtonField is not centred, am i doing something wrong ?
EDIT :
I solved this problem by using this code :
HorizontalFieldManager ButM = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER|USE_ALL_WIDTH)
{
public void paint(Graphics graphics)
{
graphics.setBackgroundColor(0x00000000);
graphics.clear();
super.paint(graphics);
}
};
ButtonField Order = new ButtonField("Tri",DrawStyle.HCENTER|ButtonField.CONSUME_CLICK);
Order.setMargin(0,0,0,(Display.getWidth()/2)-30);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这段代码将运行良好..
我已经测试过...
This code will run fine..
I have test it...
试试这段代码
Try this bit of code
试试这个..希望它能帮助你
try this.. hope it will help you