我的 NetBeans 最近更新了新的 CodenameOne 插件,它看起来像 Button.setTextPosition(Label.LEFT);在 Android 和 iOS 上呈现错误的图标位置,图标始终与文本重叠。它仍然可以正确地使用模拟器进行渲染,并且该函数仍然可以正确地使用 Label.RIGHT、Label.TOP 和 Label.BOTTOM 参数进行渲染。你有什么想法吗?
谢谢, 威廉
最佳答案
Shai,我认为问题是图标缩放到按钮的 font.getHeight() 。
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Form("Test", new BoxLayout(BoxLayout.Y_AXIS));
Font font = new Button("Test").getUnselectedStyle().getFont();
Image t = pictures.getImage("Play.png").scaled(font.getHeight(), font.getHeight());
hi.add(b(Button.LEFT, " Left 123", t))
.add(b(Button.RIGHT, " Right ", t))
.add(b(Button.TOP, " Top ", t))
.add(b(Button.BOTTOM, " Bottom ", t));
hi.add(b(Button.LEFT, " Left ", t))
.add(b(Button.RIGHT, " Right ", t))
.add(b(Button.TOP, " Top ", t))
.add(b(Button.BOTTOM, " Bottom ", t));
hi.show();
}
private Button b(int pos, String txt, Image t) {
Button btn = new Button(txt, t);
btn.setTextPosition(pos);
return btn;
}
以下是屏幕截图:
模拟器:
Nexus(安卓):
关于android - Button.setTextPosition(Label.LEFT);渲染错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34565387/