此问题会在Android上产生两个不需要的效果:
SizeChangedListener
(在应用启动时)我
不想要; Style.BACKGROUND_IMAGE_SCALED_FILL
)
刚刚开始。以下代码在Samsung Galaxy S8 +上测试,生成此日志:
12-18 00:49:45.594 D / SizeChangedListener(17264): [EDT] 0:0:0,22 - 初始屏幕尺寸:1080 * 2008 12-18 00:49:45.596 I / System.out(17264):showKeyboard false 12-18 00:49:45.623 D / Codename One(17264): sizechanged:1080 1945 com.codename1.impl.android.CodenameOneView@10f7aa8 12-18 00:49:45.627 D / libEGL(17264):已加载/vendor/lib64/egl/libGLES_mali.so 12-18 00:49:45.633 I / WebViewFactory(17264):正在加载com.google.android.webview版本60.0.3112.107(代码311210750) 12-18 00:49:45.634 D / SizeChangedListener(17264): [EDT] 0:0:0,61 - SizeChangedListener on" hi Form"调用... 12-18 00:49:45.635 D / SizeChangedListener(17264): [EDT] 0:0:0,64 - 新屏幕尺寸:1080 * 1945
这是我用来复制此问题的非常简单的代码:
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
hi.add(new Label("Hi world"));
Log.p("Initial Screen size: " + hi.getWidth() + " * " + hi.getHeight());
hi.show();
hi.addSizeChangedListener(l -> {
Log.p("SizeChangedListener on \"hi Form\" invoked...");
Log.p("New Screen size: " + hi.getWidth() + " * " + hi.getHeight());
});
答案 0 :(得分:1)
We just relay the size of the view and the events we get from Android. The reason for this is probably related to the status bar which might be hidden on launch and is then added for compatibility.
We have an RFE to enable status bar hiding on Android which might resolve this issue although with Android it might create a similar issue in other devices where the status bar isn't hidden by default...