我试图以img1 str img2 | img3格式在屏幕底部对齐图像,我面临的问题是如果str很小,图像会向左移动,否则图像会根据字符串长度。我想保持图像始终在右上角,怎么做?
VerticalFieldManager test = new VerticalFieldManager();
HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(
FIELD_BOTTOM | Manager.USE_ALL_WIDTH) {
public void paint(Graphics graphics) {
graphics.setBackgroundColor(0x316AC5);
graphics.clear();
super.paint(graphics);
}
};
Bitmap fadeBitmap = Bitmap
.getBitmapResource("icon_tz_faded_316AC5_35x39.png");
Bitmap clockBitmap = Bitmap
.getBitmapResource("icon_date_picker_white_316AC5_35x39.png");
Bitmap tzBitmap = Bitmap
.getBitmapResource("icon_tz_white_316AC5_35x39.png");
final ImageButtonField unfocus = new ImageButtonField("",
Field.FOCUSABLE | FIELD_LEFT, "icon_tz_faded_316AC5_35x39.png",
"icon_tz_faded_316AC5_35x39.png", 0xFFFFFF);
final ImageButtonField bitmapField = new ImageButtonField("",
Field.FOCUSABLE | ImageButtonField.FIELD_RIGHT,
"icon_date_picker_white_316AC5_35x39.png",
"icon_date_picker_selected_35x39.png", 0xFFFFFF);
final ImageButtonField bitmapField1 = new ImageButtonField("",
Field.FOCUSABLE | ImageButtonField.FIELD_RIGHT,
"icon_tz_white_316AC5_35x39.png", "icon_tz_selected_35x39.png",
0xFFFFFF);
int margin = ((Display.getWidth() - (fadeBitmap.getWidth()
+ clockBitmap.getWidth() + tzBitmap.getWidth() + timezoneTitle
.getWidth())) / 4);
unfocus.setMargin(0, 3, 0, 0);
timezoneTitle.setMargin(0, 120, 0, 0);
bitmapField1.setMargin(0, 0, 0, 0);
horizontalFieldManager.add(unfocus);
horizontalFieldManager.add(timezoneTitle);
horizontalFieldManager.add(bitmapField);
horizontalFieldManager.add(bitmapField1);
test.add(horizontalFieldManager);
答案 0 :(得分:0)
创建另一个水平字段并将图像添加到此字段,然后使用setPadding(顶部,左侧,底部,右侧)按顺序排列图像。