gpt4 book ai didi

android - 使用 Android 动画,情绪从中心向右滚动

转载 作者:行者123 更新时间:2023-11-29 21:16:34 27 4
gpt4 key购买 nike

我希望我的 ImageView 从屏幕中央向右滚动。我目前使用此代码,但它不会滚动图像。

final AnimationSet rollingIn = new AnimationSet(true);

Animation moving = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0,
Animation.RELATIVE_TO_PARENT, 0);
moving.setDuration(5000);

rollingIn.addAnimation(moving);

最佳答案

尝试

final AnimationSet rollingIn = new AnimationSet(true);
Animation moving = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 5, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
moving.setDuration(1000);
final Animation rotating = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotating.setDuration(1000);

rollingIn.addAnimation(rotating);
rollingIn.addAnimation(moving);

关于android - 使用 Android 动画,情绪从中心向右滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21298113/

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