gpt4 book ai didi

安卓翻译动画

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:15 25 4
gpt4 key购买 nike

我有一个位于底部上方 250dp 的 ImageView,我想将其移动到底部上方 50dp 的平移动画。

我知道如何使用平移动画,但我不知道 ToYValue 字段是什么。

代码是这样的:

TranslateAnimation translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT,0,Animation.RELATIVE_TO_PARENT,0,Animation.ABSOLUTE,250,Animation.ABSOLUTE,50);
translate.setDuration(1000);
translate.reset();
translate.setFillAfter(true);
iv.clearAnimation();
iv.startAnimation(translate);

最佳答案

您希望 fromYValue 为 0,表示从当前位置开始,toYValue 为 50,表示向下移动 50 个像素。请注意,这些值以像素为单位,而不是 dp。如果它必须在 dp 中,那就是另一个问题了..

关键在于 TranslateAnimation 文档“在动画开始时应用 Y 坐标的更改”中的“更改”一词。

http://developer.android.com/reference/android/view/animation/TranslateAnimation.html

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

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