Onlclick listener is not working properly ..?

I have a button that I rotated 45 degrees using the rotation animation and applied it to the client to set fire to the message.

When I click on the top 50% of the toast button, it is displayed. But when I click on the lower 50% button, it costs nothing.

here is the animation code.

<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="45" android:toDegrees="45" android:pivotX="50%" android:pivotY="50%" android:duration="0" android:fillAfter="true"> </rotate> 

df

Thanks in advance.....!

+6
source share
1 answer

I am sure this is a limitation of animation in Android. They fixed it in version 3.0, introducing a new animation system.

Read here: http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html

β€œFinally, previous animations changed the appearance of the targets ... but they didn’t actually change the objects themselves. You may have encountered this problem. Let's say you want to move the button from one side of the screen to the other. You can use TranslateAnimation to do this, and the button will happily slide on the other side of the screen. And when the animation is done, it will gladly return to its original location. Find the setFillAfter (true) method in the animation and try again. This time the button remains in place in that place Where it was animated. And you can check by clicking on it - Hey! How the button isn "Click" will turn out The problem is that the animation changes when the button is drawn, but not where the button physically exists in the container. If you want press the button, you need to click the location in which it was used in. Or, as a more effective solution (and one slightly more useful to your users), you will need to write your code to actually change the location of the button in the layout when the animation ends .

For these reasons, among other things, we decided to offer a new animation system in Honeycomb, built on the idea of ​​"animation of properties."

+3
source

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


All Articles