开发过程中需要做五个点的上下拉伸效果,奇怪的是第一次进行拉伸的时候是正常的,但是第二次开始就不对了,加打印看也没问题啊,实在是找不到原因,求大神看看
第一次拉伸效果:
第二次及以后的拉伸效果:
因为之前每个点还有上下移动的操作,所以我添加打印看了一下开始拉伸动画前的坐标,五个点在同一水平线上,实在是不知道为啥变成这样。
代码如下:
private static void generateSpeakingAnimation(){
Log.d(TAG, "generateSpeakingAnimation");
Log.d(TAG, "dot1.getTranslationY = " + dot1.getTranslationY());
Log.d(TAG, "dot2.getTranslationY = " + dot2.getTranslationY());
Log.d(TAG, "dot3.getTranslationY = " + dot3.getTranslationY());
Log.d(TAG, "dot4.getTranslationY = " + dot4.getTranslationY());
Log.d(TAG, "dot5.getTranslationY = " + dot5.getTranslationY());
Log.d(TAG, "dot1.getY = " + dot1.getY());
Log.d(TAG, "dot2.getY = " + dot2.getY());
Log.d(TAG, "dot3.getY = " + dot3.getY());
Log.d(TAG, "dot4.getY = " + dot4.getY());
Log.d(TAG, "dot5.getY = " + dot5.getY());
dot1.setTranslationY(0);
dot2.setTranslationY(0);
dot3.setTranslationY(0);
dot4.setTranslationY(0);
dot5.setTranslationY(0);
Log.d(TAG, "dot1.getScaleY = " + dot1.getScaleY());
Log.d(TAG, "dot2.getScaleY = " + dot2.getScaleY());
Log.d(TAG, "dot3.getScaleY = " + dot3.getScaleY());
Log.d(TAG, "dot4.getScaleY = " + dot4.getScaleY());
Log.d(TAG, "dot5.getScaleY = " + dot5.getScaleY());
Log.d(TAG, "dot1.getY = " + dot1.getY());
Log.d(TAG, "dot2.getY = " + dot2.getY());
Log.d(TAG, "dot3.getY = " + dot3.getY());
Log.d(TAG, "dot4.getY = " + dot4.getY());
Log.d(TAG, "dot5.getY = " + dot5.getY());
animSetForSpeaking = new AnimatorSet();
animSetForSpeaking.setDuration(500);
animSetForSpeaking.setInterpolator(new AccelerateDecelerateInterpolator());
ObjectAnimator animtion1 = ObjectAnimator.ofFloat(dot1, "scaleY", 1f, 5f, 1f);
animtion1.setRepeatCount(ValueAnimator.INFINITE);
animtion1.setRepeatMode(ValueAnimator.INFINITE);
ObjectAnimator animtion2 = ObjectAnimator.ofFloat(dot2, "scaleY", 1f, 10f, 1f);
animtion2.setRepeatCount(ValueAnimator.INFINITE);
animtion2.setRepeatMode(ValueAnimator.INFINITE);
ObjectAnimator animtion3 = ObjectAnimator.ofFloat(dot3, "scaleY", 1f, 5f, 1f);
animtion3.setRepeatCount(ValueAnimator.INFINITE);
animtion3.setRepeatMode(ValueAnimator.INFINITE);
ObjectAnimator animtion4 = ObjectAnimator.ofFloat(dot4, "scaleY", 1f, 10f, 1f);
animtion4.setRepeatCount(ValueAnimator.INFINITE);
animtion4.setRepeatMode(ValueAnimator.INFINITE);
ObjectAnimator animtion5 = ObjectAnimator.ofFloat(dot5, "scaleY", 1f, 5f, 1f);
animtion5.setRepeatCount(ValueAnimator.INFINITE);
animtion5.setRepeatMode(ValueAnimator.INFINITE);
animSetForSpeaking.playTogether(animtion1, animtion2, animtion3, animtion4, animtion5);
animSetForSpeaking.start();
}
log打印里面显示5个点的getScaleY都是1,还有在进行setTranslationY之后5个点的getY也都是一样的值,应该不存在点的位置发生变化的情况,所以感觉很诡异,求高手解答~~
亲测了一下 没有出现你的那种情况 是不是模拟器的问题