我正试图在scrollview
中为10个观看动画,但问题是。
动画仅在scrollview
停止滚动时启动。
我想在滚动scrollview
时动画显示。
LayoutInflater inflater = LayoutInflater.from(this);
final View view = inflater.inflate(R.layout.view_albumview, null);
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
imageView.setBackgroundResource(R.drawable.image_temp01);
view.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
System.out.println(">>>>>" + view.getX());
if (detectOverLap(view, mainRect)) {
ObjectAnimator objectanimator1, objectanimator2;
objectanimator1 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleX", 1.0f);
objectanimator2 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleY", 1.0f);
objectanimator1.start();
objectanimator2.start();
System.out.println("ON INNER");
}
}
});
return view;
这是在随机位置的滚动视图中添加的视图
由于 阿米特夏尔马
答案 0 :(得分:0)
帮助我的解决方案是将ObjectAnimator的动画持续时间设置为零并设置插值器。所以你的代码应该是这样的:
System.out.println(">>>>>" + view.getX());
if (detectOverLap(view, mainRect)) {
ObjectAnimator objectanimator1, objectanimator2;
objectanimator1 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleX", 1.0f);
objectanimator2 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleY", 1.0f);
objectanimator1.setInterpolator(new FastOutSlowInInterpolator());
objectanimator2.setInterpolator(new FastOutSlowInInterpolator());
objectanimator1.setDuration(0);
objectanimator2.setDuration(0);
objectanimator1.start();
objectanimator2.start();
System.out.println("ON INNER");
}