代号一-避免在应用启动时在Android上更改屏幕大小 [英] Codename One - Avoid screen size change on Android on app startup
问题描述
此问题在Android上产生了两个不良影响:
This issue produce two unwanted effects on Android:
- 执行一次
SizeChangedListener
(在应用启动时)我
不需要的内容; - 表单背景
的可见大小和不需要的大小调整(带有选项Style.BACKGROUND_IMAGE_SCALED_FILL
)在应用程序刚刚启动
之后。
- one execution of the
SizeChangedListener
(at app startup) that I don't want; - a visible and unwanted resizing of the Form background
(with the option
Style.BACKGROUND_IMAGE_SCALED_FILL
) after the app is just started.
以下代码(在Samsung Galaxy S8 +上测试),会生成以下日志:
The following code, tested on Samsung Galaxy S8+, produces this log:
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):大小已更改: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.3 112.107(代码311210750)
12-18 00:49:45.634 D / SizeChangedListener(17264): [EDT] 0:0:0,61-调用 hi Form上的SizeChangedListener ...
12-18 00:49:45.635 D / SizeChangedListener(17264): [EDT] 0:0:0,64-新屏幕尺寸:1080 * 1945
12-18 00:49:45.594 D/SizeChangedListener(17264): [EDT] 0:0:0,22 - Initial Screen size: 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): loaded /vendor/lib64/egl/libGLES_mali.so 12-18 00:49:45.633 I/WebViewFactory(17264): Loading com.google.android.webview version 60.0.3112.107 (code 311210750) 12-18 00:49:45.634 D/SizeChangedListener(17264): [EDT] 0:0:0,61 - SizeChangedListener on "hi Form" invoked... 12-18 00:49:45.635 D/SizeChangedListener(17264): [EDT] 0:0:0,64 - New Screen size: 1080 * 1945
这是我用来复制此问题的非常简单的代码:
This is the very simple code that I used to replicate this issue:
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());
});
推荐答案
我们只是中继视图和事件的大小我们从Android获得。其原因可能与状态栏有关,状态栏可能在启动时隐藏,然后为了兼容性而添加。
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.
我们有一个RFE来启用状态隐藏在Android上的栏可能会解决此问题,尽管使用Android可能会在其他默认情况下未隐藏状态栏的设备中创建类似的问题...
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...
这篇关于代号一-避免在应用启动时在Android上更改屏幕大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!