How To Properly Move A View?
Solution 1:
What you have is basically fine, with two flaws:
You are using
setFillAfter()
, which is not especially usefulYou are calling
layout()
andsetRight()
and stuff, which is not especially effective
Instead, in onAnimationEnd()
, you need to modify the LayoutParams
of the View
to reflect the new position you want the widget to be in. The size and position of a widget is dictated by the layout rules it negotiates with its container. Initially, those are set via your layout XML resource. By modifying the LayoutParams
at runtime, you are changing what those rules are.
What those LayoutParams
are (LinearLayout.LayoutParams
, RelativeLayout.LayoutParams
, etc.) and what values you should specify in them, we cannot tell you, because we don't know what you are doing.
Post a Comment for "How To Properly Move A View?"