gpt4 book ai didi

Android Alpha/翻译动画

转载 作者:太空宇宙 更新时间:2023-11-03 12:19:50 25 4
gpt4 key购买 nike

我有这个动画,它应该在淡出时将应用的 View 向上移出 View ,将其移回 View 下方,然后在淡入淡出时移回 View 。

问题是它似乎没有褪色 - 应用 View 的不透明度始终为 0.5

<?xml version="1.0" encoding="UTF-8" ?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate
android:fromYDelta="0"
android:toYDelta="-200"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1995"
android:startOffset="3000" />
<translate
android:fromYDelta="200"
android:toYDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1995"
android:startOffset="8005" />

<alpha
android:duration="500"
android:fromAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:repeatMode="reverse"
android:startOffset="3000"
android:toAlpha="0.5" />
<alpha
android:duration="1995"
android:fromAlpha="0.5"
android:interpolator="@android:anim/accelerate_interpolator"
android:repeatMode="reverse"
android:startOffset="8005"
android:toAlpha="1.0" />
</set>

我已经尝试了很多方法,将它们嵌套在集合中,删除插值器等......唯一有效的方法是使用这个 SO 问题中给出的示例:android two alpha animations这让我相信这与在与平移动画结合时运行 alpha 动画有关。

谢谢!

最佳答案

这是一个例子:

AnimationSet set = new AnimationSet(true);
Animation trAnimation = new TranslateAnimation(0, 500, 0, 0);
trAnimation.setDuration(6000);

trAnimation.setRepeatMode(Animation.REVERSE); // This will make the view translate in the reverse direction

set.addAnimation(trAnimation);
Animation anim = new AlphaAnimation(1.0f, 0.0f);
anim.setDuration(3000);
set.addAnimation(anim);

txtView.startAnimation(set); // replace this with your view

希望对您有所帮助!您可以更改此设置并使用基于布局的动画定义 alpha 并在 set 标签下转换动画。

关于Android Alpha/翻译动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19184196/

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