使用 SwipeBacksupport 滑动表单会使整个屏幕变白

Swiping form using SwipeBacksupport turns entire screen white

  1. 滑动表单时,屏幕左侧不断增长的部分只是白色,直到滑动完成,"back-to" 表单才最终被绘制。这是设计使然吗?我预计 "back-to" 表格要么逐渐显示,要么从左侧滑入。

  2. 在iOS和Android上,被滑动的表单好像也变白了,所以整个屏幕都是白色的,直到滑动结束。然而,在模拟器中情况并非如此,您可以在其中看到表单,直到它完全滑出。

重现行为的代码:

    Form redForm = new Form("Red Form");
    redForm.getAllStyles().setBgColor(0xff0000);
    Button btnToBlueForm = new Button("Go to blue form");
    redForm.add(btnToBlueForm);

    Form blueForm = new Form("Blue Form"); 
    blueForm.getAllStyles().setBgColor(0x0000ff);

    LazyValue<Form> lazyRedForm = (Object... args) -> redForm;
    SwipeBackSupport.bindBack(blueForm, lazyRedForm); 

    btnToBlueForm.addActionListener((ActionListener<ActionEvent>) (ActionEvent evt) -> {
        blueForm.show();
        SwipeBackSupport.bindBack(blueForm, lazyRedForm);
    });

    redForm.show();

按红色表格中的按钮。现在出现蓝色表格。向后滑动并观察效果。

那是因为过渡中的 SlideFade 模式。如果您将它切换到幻灯片,它应该可以像预期的那样在背景中工作。这是您的代码版本,通过将样式应用于内容窗格,它可以像您期望的那样工作:

Form redForm = new Form("Red Form");
redForm.getContentPane().getAllStyles().setBgColor(0xff0000);
redForm.getContentPane().getAllStyles().setBgTransparency(255);

Button btnToBlueForm = new Button("Go to blue form");
redForm.add(btnToBlueForm);

Form blueForm = new Form("Blue Form"); 
blueForm.getContentPane().getAllStyles().setBgColor(0x0000ff);
blueForm.getContentPane().getAllStyles().setBgTransparency(255);

LazyValue<Form> lazyRedForm = (Object... args) -> redForm;
SwipeBackSupport.bindBack(blueForm, lazyRedForm); 

btnToBlueForm.addActionListener((ActionListener<ActionEvent>) (ActionEvent evt) -> {
    blueForm.show();
    SwipeBackSupport.bindBack(blueForm, lazyRedForm);
});

redForm.show();

这与原始代码相反的原因是 SlideFade 是两个独立的过渡,一个 moving/fading 标题和另一个单独滑动内容窗格。由于内容窗格是透明的,因此没有绘制背景,因为我们假设它是表单背景。通过设置内容窗格 color/opacity,我们在 SlideFade 将 "see".

的图层上获得完全相同的效果