这些是6个仪表板按钮:需要水平居中
![\[1\]: http://i.stack.imgur.com/jg6q8.png][1]
目前的代码如下:
DashboardButtons = new VerticalFieldManager(Field.USE_ALL_WIDTH
| VerticalFieldManager.FIELD_HCENTER));
ButtonRow1 = new HorizontalFieldManager(Field.USE_ALL_WIDTH
| HorizontalFieldManager.FIELD_HCENTER);
ButtonRow2 = new HorizontalFieldManager(Field.USE_ALL_WIDTH
| HorizontalFieldManager.FIELD_HCENTER);
字段的定义如下: b1 = new Field(Field.FOCUSABLE | FIELD_HCENTER)
在字段中我添加了按钮图像。
顶部的图标(居中)直接添加到使用Field.USE_ALL_WIDTH定义的VerticalFieldManager中。 VerticalFieldManager.FIELD_HCENTER`和带有FIELD_HCENTER的图标字段
答案 0 :(得分:1)
我根据你可以修改的代码给你一个示例代码:
如果您想要关注图像,您应该在ONFOCUS中提供一个图像,在UNFOCUS上提供另一个图像。
以下是示例代码:
public class LoadingScreen extends MainScreen
{
Font font;
VerticalFieldManager vertical;
Bitmap bitmap=Bitmap.getBitmapResource("btn_send.png");
BitmapField bitmapField;
ButtonField plus,minus;
int px=0;
int py=0;
public LoadingScreen()
{
font=Font.getDefault().derive(Font.BOLD, 18);
createGUI();
}
public void createGUI()
{
vertical=new VerticalFieldManager(USE_ALL_WIDTH);
HorizontalFieldManager hor=new HorizontalFieldManager(Field.FIELD_HCENTER);
BitmapField bitmapField=new BitmapField(bitmap);
hor.add(bitmapField);
vertical.add(hor);
HorizontalFieldManager hr=new HorizontalFieldManager(Field.FIELD_HCENTER);
BitmapField bitmapField1=new BitmapField(bitmap);
hr.add(bitmapField1);
BitmapField bitmapField2=new BitmapField(bitmap);
hr.add(bitmapField2);
BitmapField bitmapField3=new BitmapField(bitmap);
hr.add(bitmapField3);
hr.setPadding(10, 0, 10, 0);
vertical.add(hr);
HorizontalFieldManager hr1=new HorizontalFieldManager(Field.FIELD_HCENTER);
BitmapField bitmapField4=new BitmapField(bitmap);
hr1.add(bitmapField4);
BitmapField bitmapField5=new BitmapField(bitmap);
hr1.add(bitmapField5);
BitmapField bitmapField6=new BitmapField(bitmap);
hr1.add(bitmapField6);
hr1.setPadding(10, 0, 10, 0);
vertical.setBackground(BackgroundFactory.createSolidBackground(Color.GREEN));
vertical.add(hr1);
add(vertical);
}
}
我在下面有这样的图片: