【问题标题】:codename one animate forground of label代号一个标签的动画前景
【发布时间】:2017-04-28 23:32:07
【问题描述】:

这对我不起作用。我正在尝试更改颜色 当我按下按钮时。

 Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS));
    Button button = new Button("button");

    Label l = new Label(" ");
    l.setUIID("DestinationUIID");
    l.getAllStyles().setFgColor(0xff0000);

    Label l$ = new Label("Label");
    l$.setUIID("DestinationUIID");
    l$.getAllStyles().setFgColor(0x00ff00);

    hi.add(l$);

    ComponentAnimation ca = l$.createStyleAnimation("DestinationUIID", 2000);
    l$.getAnimationManager().addAnimation(ca, () -> onCompletion());

    button.addActionListener((e) -> {

        //l$.animate();
        l$.getAllStyles().setFgColor(0xff0000);
         l$.animate();
        //hi.getContentPane().animateHierarchyFade(2000, 0);
    });
    hi.add(button);
    hi.show();

我不了解 UIID 的概念或动画的语法。

【问题讨论】:

    标签: label codenameone opacity foreground


    【解决方案1】:

    从样式动画到 animate() 调用到 UITimer,有很多方法可以为前景设置动画。

    使用样式动画,我们可以为 500 毫秒的过渡做这样的事情:

    ComponentAnimation ca = myLabel.createStyleAnimation("DestinationUIID", 500);
    myLabel.getAnimationManager().addAnimation(ca, () -> onCompletion());
    

    【讨论】:

    • 您建议另一个用户,“您需要创建一个源 UIID 和目标 UIID,因为我们使用它们来重置状态。”但是,我们都对如何做到这一点的语法感到困惑。我不明白java中动画的概念,或者UIID的概念......
    • UIID 是在主题中定义的,因此您需要在设计器中打开主题,方法是打开 theme.res 文件并使用 Add 添加定义组件外观的条目,请参阅:@987654321 @ 一旦你这样做了,你就可以应用类似这个动画的东西来在两种状态之间转换。因此,假设您有一个带有Button UIID 的Button,您可以将其转换为ButtonRed,您可以将其定义为从Button 主题派生,同时将fgColor 覆盖为红色。
    猜你喜欢
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 2013-01-19
    • 2013-08-05
    • 2019-10-28
    • 2015-03-20
    相关资源
    最近更新 更多