Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Onlclick listener is not working properly..?

I have button, which i rotated 45 degrees using rotate animation and applied on click listener that toasting a message.

When i click on upper 50% of the button toast is displaying. But when i click on lower 50% of the button nothing is displying.

here 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.....!

like image 417
Noby Avatar asked Nov 07 '11 13:11

Noby


1 Answers

I'm pretty sure this is a limitation of animation in Android. They fixed it in 3.0 onwards by implementing a new animation system.

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

"Finally, the previous animations changed the visual appearance of the target objects... but they didn't actually change the objects themselves. You may have run into this problem. Let's say you want to move a Button from one side of the screen to the other. You can use a TranslateAnimation to do so, and the button will happily glide along to the other side of the screen. And when the animation is done, it will gladly snap back into its original location. So you find the setFillAfter(true) method on Animation and try it again. This time the button stays in place at the location to which it was animated. And you can verify that by clicking on it - Hey! How come the button isn't clicking? The problem is that the animation changes where the button is drawn, but not where the button physically exists within the container. If you want to click on the button, you'll have to click the location that it used to live in. Or, as a more effective solution (and one just a tad more useful to your users), you'll have to write your code to actually change the location of the button in the layout when the animation finishes.

It is for these reasons, among others, that we decided to offer a new animation system in Honeycomb, one built on the idea of "property animation."

like image 124
Damian Avatar answered Nov 17 '22 14:11

Damian