gpt4 book ai didi

android-animation - 如何沿 x 轴旋转 View

转载 作者:行者123 更新时间:2023-12-04 23:52:43 25 4
gpt4 key购买 nike

我想沿其 x 轴旋转 View 。我尝试执行以下操作:

AnimationSet anim=new AnimationSet(true);
RotateAnimation rotate=new RotateAnimation(0.0f,-10.0f,RotateAnimation.ABSOLUTE,0.5f,RotateAnimation.RELATIVE_TO_SELF,0.5f);
rotate.setFillAfter(true);
rotate.setDuration(5000);
rotate.setRepeatCount(0);
anim.addAnimation(rotate);
View relatv1=(View)findViewById(R.id.relativeLayout1);
relatv1.setAnimation(anim);

但我相反, View 沿其 y 轴旋转。我怎样才能完成 x 轴旋转?

最佳答案

像这样使用 ObjectAnimator:

    ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationX", 0.0f, 360f);
animation.setDuration(5000);
animation.setRepeatCount(ObjectAnimator.INFINITE);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();

关于android-animation - 如何沿 x 轴旋转 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20215076/

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