Issue
My MapView contains child view added by addView() with LayoutParams:
new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, geoPoint, 0, 0, MapView.LayoutParams.BOTTOM | MapView.LayoutParams.LEFT)
I can get screen point of my view:
Point p1 = mapView.getProjection().toPixels(geoPoint, null);
When geoPoint changes I remove all childs of mapView and then add my view with new LayoutParams (based on new geoPoint) and get new on screen point:
Point p2 = mapView.getProjection().toPixels(newGeoPoint, null);
Now I need to translate view from p1 to p2, I try:
Animation animation = new TranslateAnimation(
Animation.ABSOLUTE, p1.x,
Animation.ABSOLUTE, p2.x,
Animation.ABSOLUTE, p1.y,
Animation.ABSOLUTE, p2.y);
animation.setDuration(1500);
myView.startAnimation(animation);
Animation plays but from wrong point to wrong point.
How can I make correct translate animation from p1 to p2.
Solution
Try this:
Animation animation = new TranslateAnimation(0, p1.x - p2.x, 0, p1.y - p2.y);
animation.setDuration(1500);
myView.startAnimation(animation);
And finally do not forget to set your point's new position, otherwise it'll turn back to ex position when animation is finished.
Answered By - yahya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.