Does Matrix.setTranslate () only transform the visual surface of the View, not the clickable zone?

I created a simple animation-based class and added an onclick listener to the view (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 just get a reference to the Matrix Translation object and call setTranslate. So the translation looks great, but if I try to click again where I now see the object (the translated location), nothing happens. If I return to the original location and clicking, it will repeat the same animation from the same starting point. I got the impression that the translation will actually translate the object itself, and not just the visual representation. Is there a way to do what I expected from the animation class? Or is there another standard way to do such things? Any insight into why this behavior is the way it is? Thanks.

+4
source share
2 answers

There is no document saying that it only modifies the matrix. If you want to actually change the rest of the interpretation of the system in the view, install an animation listener that sets the position when the animation ends.

0
source

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

0
source

Source: https://habr.com/ru/post/1299050/


All Articles