当前位置: 首页 > 知识库问答 >
问题:

Codename One-如何在BorderLayout中使用onTitleScrollAnimation?

孟俊发
2023-03-14

由于Toolbar API的最后一节中提到了滚动动画特性的Toolbar或Titlearea,也在这篇精彩的视频教程中提到了(大约从分钟45开始),动画在给定的情况下工作得很好。

我无法找到关于这些必须是什么的任何文档,但我发现了一种情况,在这种情况下,它不起作用。下面是一个演示该问题的工作示例:

        Form hi = new Form("Title", new BoxLayout(BoxLayout.Y_AXIS));
        EncodedImage placeholder = EncodedImage
                .createFromImage(Image.createImage(hi.getWidth(), hi.getWidth() / 5, 0xffff0000), true);
        URLImage background = URLImage.createToStorage(placeholder, "400px-AGameOfThrones.jpg",
                "http://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/400px-AGameOfThrones.jpg");
        background.fetch();
        Style stitle = hi.getToolbar().getTitleComponent().getUnselectedStyle();
        stitle.setBgImage(background);
        stitle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
        stitle.setPaddingUnit(Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS);
        stitle.setPaddingTop(15);

//      hi.setLayout(new BorderLayout()); // uncomment this for the animation to break
        Container contentContainer = new Container(BoxLayout.y());
        contentContainer.setScrollableY(true);
        // add some elements so we have something to scroll
        for (int i = 0; i < 50; i++)
            contentContainer.add(new Label("Entry " + i));
        hi.add(contentContainer);
//      hi.add(BorderLayout.CENTER, contentContainer); // use this line instead of the above for the animation to break

        ComponentAnimation anim = hi.getToolbar().getTitleComponent().createStyleAnimation("Title", 200);
        hi.getAnimationManager().onTitleScrollAnimation(anim);
        hi.show();

共有1个答案

巴洲
2023-03-14

适配器绑定到窗体内容窗格滚动,因此如果您在这里有边框布局,它将无法工作。在这种情况下,不会检测到滚动,因为代码只是不知道滚动。它需要跟踪UI中任何组件的滚动以检测滚动。

 类似资料:
  • 我决定在Netbeans GUI builder(又名Matisse)中更改组件的布局。 现在它完全搞砸了我的面板。我想在中心添加一个主面板(即默认),然后在左边或右边添加其他组件,然而在Netbeans中,我没有看到构建器中添加一些北方、南方等的选项。

  • 我想压缩(收缩)项目大小。我想知道在build.xml中应该在哪里添加这个属性“compress=true”。你能为它提供一些示例代码吗?

  • 介绍 (Introduction) BorderLayout类安排组件适合五个区域:东,西,北,南和中心。 每个区域只能包含一个组件,每个区域中的每个组件都由相应的常量NORTH,SOUTH,EAST,WEST和CENTER标识。 类声明 以下是java.awt.BorderLayout类的声明: public class BorderLayout extends Object

  • 介绍 (Introduction) BorderLayout类安排组件适合五个区域:东,西,北,南和中心。 每个区域只能包含一个组件,每个区域中的每个组件都由相应的常量NORTH,SOUTH,EAST,WEST和CENTER标识。 Class 声明 (Class Declaration) 以下是java.awt.BorderLayout类的声明 - public class BorderLayou

  • 我创建了一个新的Codenameone项目。它包含以下代码: 会有什么问题? 谢了。