Nativescript - 如何在水龙头上打开布局

时间:2017-12-21 14:09:46

标签: nativescript

我有一个StackLayout,其中一个条目是固定大小的GridLayout。通常,此GridLayout不可见。

点按一个按钮,我希望GridLayout可见 - 但我想将它打开动画 - 就像菜单打开一样。

有什么想法吗?

实际上,切换可见性并不是太糟糕 - 它似乎为开放动画 - 任何控制速度的方法?

关闭操作对我想要实现的目标来说可能太快了。

1 个答案:

答案 0 :(得分:1)

您可以为网格的不透明度设置动画。所以当你点击它时你会

// View is your gridView, this would hide it completely
view.opacity = 0;

// when you want to show it.
// fade in view.
view.animate({
        opacity: 1,
        duration: 250 
        }).then(() => {
            //Set the visibility to collapsed after the animation is complete 
            //I believe you will want to do this so that the surrounding views adjust accordingly. 
            view.visibility='collapse';
        }, (err) => {});

// when you want to hide it.
// fade out.
view.animate({
        opacity: 0,
        duration: 250 
        }).then(() => {
           view.visibility='visible';
        }, (err) => {});

您可能还想查看动画的翻译,这样您就可以按照自己想要的方式向下,向左,向上,向右移动视图。

相关问题