android - Button.setTextPosition(Label.LEFT);渲染错误

标签 android ios codenameone

我的 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;
}

以下是屏幕截图:

模拟器:

Simulator's screenshot

Nexus(安卓):

Nexus's screenshot

关于android - Button.setTextPosition(Label.LEFT);渲染错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34565387/

相关文章:

java - 在 SearchView.onQueryTextSubmit() 和 AsyncTask 上更新 ListView

ios - IBM 工作灯 v6.1.0.1 : Error when using Ionic Framework with Worklight and run on IOS environment

codenameone - Codename 一种具有百分比宽度和自适应高度的自定义布局

java - 代号一 : Why am I getting "/by zero" when trying to scale an image

components - 代号一组件形状

java - 下划线 EditText 提示文本

java - 调用 OnFailure 并抛出 IOException 但数据已发布

android - Android 上的 Dropbox 核心 API - 重用 token

ios - 如何获得作为呈现 View Controller 的顶 View

ios - 是否有适用于 iPhone/iPad 生态系统的可靠崩溃报告系统?