![]() ![]() Var y = e.Event.GetY() - (_child.Height / 2) Var x = e.Event.GetX() - (_child.Width / 2) the center point lies over the touch point position the top left of the child view such that Private void OnTouch(object sender, View.TouchEventArgs e) _animation.AnimationEnd += OnAnimationEnd _animation = AnimationUtils.LoadAnimation(context, ) _child.Visibility = ViewStates.Invisible _layoutParams = new RelativeLayout.LayoutParams(64, 64) Public Parent(Context context, IAttributeSet attrs) Parent View Class public class Parent: RelativeLayout My new question now is: What method can I use to position the child absolutely in the parent without it being affected by scaling? ![]() ![]() How can I move the child element and ensure the animation applied to it still pivots around the local centre point, and what exactly is causing this behaviour I'm currently seeing?Įdit: I've discovered that the root cause of this is that the animation scales the x and y coordinates of the child as well as its width and height, hence when the scale is 0 the child appears at the origin of the parent element, and when the scale is 1 it appears in the correct position. This leads me to think that somehow the animation pivot is being interfered with. The result I'm currently seeing is that the child always begins the animation at the upper-left corner of the parent and appears to translate to the point the user tapped while scaling and fading properly. The expand animation is a simple fade in and scale which should pivot around the centre of the child. The parent has a fixed size and position, and the child is supposed to expand into view where the user taps the parent. I have a custom parent view with a single child view. I'm working in Xamarin (C#) but Java solutions are fine. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |