Change position of view after end of animation

前端 未结 3 528
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 15:58

I develop a widget based on ViewGroup and my problem is that I need to save position of items after the end of animation. I called setFillAfter(true) i

3条回答
  •  广开言路
    2021-02-04 16:23

    You must use ObjectAnimator , it works from API 11 level . It changes View position automatic,

    here is the example

    ObjectAnimator objectAnimator= ObjectAnimator.ofFloat(mContent_container, "translationX", startX, endX);
    objectAnimator.setDuration(1000);
    objectAnimator.start();
    

    Thanks JUL for his answer

    If your app not found object animator, change the API level from Project -> properties -> Android , than import android.animation.ObjectAnimator;

提交回复
热议问题