Move view itself to animation's end position

血红的双手。 提交于 2020-01-05 15:14:34

问题


I'm having a real serious problem. I want to implement UI where some view is moving on the screen and the user can touch it. I know that regular API-1 Animation framework move just the graphics of the view, and API-11 Animator framework move the view itself, but the problem is that it support only API-11+ which is very high.

I thought that instead of putting click listener on the view itself - I will identify which item was clicked by getting its position. So this is what I will do: * User touch the screen. * Stop all the animations. * Get all the animated views to the position where the animation was ended. (This is were I need your help). * Iterate over the views and find out if the click was in the area of one of them.

But I can't find a way to move the view to the animation's end position.

If someone knows a way, I will be very thankful!

Thanks in advance, Elad


回答1:


But I can't find a way to move the view to the animation's end position.

Modify its LayoutParams to move it to the end position. Use getLayoutParams() on the View, cast it to the appropriate type based on its container, modify the LayoutParams object, then call setLayoutParams() on the View to commit the changes.



来源:https://stackoverflow.com/questions/12132412/move-view-itself-to-animations-end-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!