我试图在我的应用程序上创建一个登录屏幕,看起来像城市指南登录屏幕(2):
我从Materiall Design Demo和PSD To App Revisited博客的博客中使用了以下代码:
f = new Form(new BorderLayout());
f.setUIID("loginForm");
f.getTitleArea().setUIID("Container");
f.getToolbar().hideToolbar();
Label logo = new Label();
logo.setIcon(theme.getImage("logoHolder.png"));
Container titleContainer = Container.encloseIn(
new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER),
logo, BorderLayout.CENTER);
titleContainer.setUIID("loginTitleContainer");
TextField login = new TextField("", "Your email address", 40, TextField.EMAILADDR);
TextField password = new TextField("", "Your password", 40, TextField.PASSWORD);
login.getAllStyles().setMargin(LEFT, 0);
password.getAllStyles().setMargin(LEFT, 0);
Label loginIcon = new Label("", "TextField");
Label passwordIcon = new Label("", "TextField");
loginIcon.getAllStyles().setMargin(RIGHT, 0);
passwordIcon.getAllStyles().setMargin(RIGHT, 0);
FontImage.setMaterialIcon(loginIcon, FontImage.MATERIAL_MAIL_OUTLINE, 3);
FontImage.setMaterialIcon(passwordIcon, FontImage.MATERIAL_LOCK_OUTLINE, 3);
Button loginButton = new Button();
loginButton.setIcon(theme.getImage("login_login.png"));
loginButton.setUIID("removePadding");
Button exitButton = new Button();
exitButton.setIcon(theme.getImage("login_exit.png"));
exitButton.setUIID("removePadding");
Button forgotButton = new Button("Forgot password?");
forgotButton.setUIID("forgotPass");
Label vSpacer = new Label();
vSpacer.setUIID("longVSpacer");
Label vSpacer1 = new Label();
vSpacer1.setUIID("longVSpacer");
Label vSpacer2 = new Label();
vSpacer2.setUIID("vSpacer");
Label vSpacer3 = new Label();
vSpacer3.setUIID("vSpacer");
Container loginCon = BoxLayout.encloseY(
vSpacer1,
BorderLayout.center(login).
add(BorderLayout.WEST, loginIcon),
BorderLayout.center(password).
add(BorderLayout.WEST, passwordIcon),
vSpacer,
loginButton,
vSpacer2,
exitButton,
vSpacer3,
forgotButton
);
f.add(BorderLayout.NORTH, titleContainer);
f.add(BorderLayout.CENTER, loginCon);
f.show();
现在,对于UIID,“removePadding”将所有填充设置为零,并将左边距设置为3 .
vSpacer设置了顶部和底部边距,以便允许垂直的合理空间 .
当我没有将文本字段添加到框布局时,一切正常,但是一旦我向框布局添加任何文本字段,北容器就会从左右收缩,并且它不会覆盖整个宽度 .
但是当从框布局中删除文本字段并添加按钮时,例如北容器覆盖整个宽度 .
我尝试使用按钮UIID“removePadding”填充和边距,但没有运气 .
以下是在边框布局中添加文本字段以及图标时我的屏幕的样子:
当我从框布局中取下文本字段并且只留下按钮时,这就是我的屏幕的样子:
此外,文本字段在未选择的UIID上都具有下划线图像 . 但是当电子邮件字段未被选中时,它不会获得下划线外观,并且只有密码字段在未被选中时加下划线 . 这看起来像个错误!!