尝试使用setMargin(5,5,5,5)
而不是setPadding(5,5,5,5)
。
Field#setMargin()
保证金是现场外的区域,边界之后。由于这些重叠,经理正确分配利润率。
Field#setPadding()
填充是内容和边框之间的区域内的区域。
Field#SetBorder()
边框是填充之外和边距之前的区域内的区域。
UPDATE:
你是正确的,与setMargin()
更换setPadding()
而已,并没有产生预期的结果。原因是您正在使用的Border
,更准确地说它的厚度()和样式(STYLE_SOLID)。减小边框厚度至并将其更改为STYLE_FILLED。
上述变化
而且现在的代码片段后:
public class PlayingWithBorders extends MainScreen {
public PlayingWithBorders() {
super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL | USE_ALL_HEIGHT | USE_ALL_WIDTH);
VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH);
vfm.setBackground(BackgroundFactory.createSolidBackground(Color.CYAN));
BasicEditField emailField = new BasicEditField();
emailField.setLabel("Email: ");
emailField.setPadding(5, 5, 5, 5);
emailField.setMargin(5, 5, 5, 5);
emailField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED));
emailField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
BasicEditField passwordField = new BasicEditField();
passwordField.setLabel("Password: ");
passwordField.setPadding(5, 5, 5, 5);
passwordField.setMargin(5, 5, 5, 5);
passwordField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED));
passwordField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
vfm.add(emailField);
vfm.add(passwordField);
add(vfm);
}
欢迎#1。图像附件固定。 – menjaraz 2012-03-21 13:58:41
检查我的更新我的答案。 – mrvincenzo 2012-03-22 10:16:03