如何在Android中实现从左到右的动画
我想在我的应用程序中如何在Android中实现从左到右的动画,android,android-animation,Android,Android Animation,我想在我的应用程序中左向右箭头动画,如下图所示: 我尝试了以下代码: ImageView arrowImage = sbView.findViewById(R.id.arrowID); ScaleAnimation scale = new ScaleAnimation(0.5f, 0.5f, 1, 1, ScaleAnimation.RELATIVE_TO_SELF, .5f, ScaleAnimation.RELATIVE_TO_SELF, .5f);
左向右箭头动画
,如下图所示:
我尝试了以下代码:
ImageView arrowImage = sbView.findViewById(R.id.arrowID);
ScaleAnimation scale = new ScaleAnimation(0.5f, 0.5f, 1, 1, ScaleAnimation.RELATIVE_TO_SELF, .5f,
ScaleAnimation.RELATIVE_TO_SELF, .5f);
scale.setDuration(700);
scale.setRepeatCount(INFINITE);
scale.setRepeatMode(REVERSE);
scale.setFillAfter(true);
scale.setInterpolator(new OvershootInterpolator());
arrowImage.startAnimation(scale);
但是我的代码没有像我期望的那样工作。我尝试了不同于internet的解决方案,但没有达到效果。这是翻译,请尝试翻译想象
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
这是翻译,试试翻译想象
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
动画XML文件
对于手柄移动位置,使用xml属性fromXDelta
和toXDelta
更改值
- android:fromXDelta
- android:toXDelta
fromXDelta
和toXDelta
更改值
- android:fromXDelta
- android:toXDelta
viewObject.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.filename));