gpt4 book ai didi

android - Viewflipper - 垂直 slider

转载 作者:太空狗 更新时间:2023-10-29 14:25:41 25 4
gpt4 key购买 nike

我已经使用 Viewflipper 做了 slider ,我们可以说从右到左表示水平 slider 。
但我想让它从顶部(从顶部开始)到底部(从底部开始)意味着垂直 slider 。
下面是我的水平滑动代码。

public static Animation inFromRightAnimation(int duration) {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromRight.setDuration(duration);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}

public static Animation outToLeftAnimation(int duration) {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
outtoLeft.setDuration(duration);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}

我需要做哪些更改才能使其垂直(从上到下)滑动?

最佳答案

public static Animation inFromUpAnimation(int duration) {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromRight.setDuration(duration);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}

public static Animation outToDownAnimation(int duration) {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f
);
outtoLeft.setDuration(duration);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}

这些属性与 x 和 y 坐标有关。我认为这会完成工作

关于android - Viewflipper - 垂直 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12870598/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com