Matrix.setTranslate() only translates the visual surface of the View and not the clickable area?

By : Rich
Source: Stackoverflow.com
Question!

I created a simple Animation-derived class and added an onclick listener to a view (a LinearLayout in this example, just to make a quick proof-of-concept) that called startAnimation on the object (passing it an instance of my class). In my Animation class, I simply get a reference to the Translation's Matrix object and call setTranslate. So, the translation looks fine, but if I attempt to click again where I now see the object (the translated location), nothing happens. If I go back to the original location and click, it repeats the same animation from the same starting point. I was under the impression that the translation would actually translate the object itself and not just the visual representation. Is there a way to do what I was expecting to happen with an animation class? Or, is there some other standard way of doing this sort of thing? Any insight into why this behavior is the way it is? Thanks.

By : Rich


Answers

Nope the documentation states that it only modifies the matrix. If you want to actually change the rest of the system's interpretation of the view, set an animation listener that sets the position when the animation ends.



You can use View.setTranslationX() and View.setTranslationY(), those should do the trick in Android Honeycomb and after :)



This video can help you solving your question :)
By: admin