Skip to content Skip to sidebar Skip to footer

Android Animation - Button Stays Clickable

I am making a game in which I have 5 buttons, looking like clouds, falling from the 'sky'. That means that when my activity starts, 'clouds' cannot be seen, since the marginTop is

Solution 1:

After doing some research, I found out that there are two types of animations:

View Animation and Property Animation.

The view animation can only animate View objects. It also lack a variety of animations, since it can do only stuff as scale, rotate, move... It cannot change background color, for example. Also, the disadvantage of the View Animation is that it only change the position of where the View object is DRAWN. Physically, it still stays in the same position. That's why the button is un-clickable, after the View Animation is finished upon it.

Property Animation, in the other hand, can animate both View and non-View objects and it doesn't have constraints as the View Animation. When objects are moved, for example, with the property animation, they are not just drawn on some other position on the screen, but they are actually MOVED there.

Now, Property Animation is a lot more complex to write than the View Animation, so if you don't really need all the advantages of the Property Animation, it is suggested to use View Animation.

Source: Property vs View Animation

Tutorial and SupportLybrary up to API 1: nineoldandroids

Solution 2:

You can change the buttons to imageViews and then do

 imageView.setOnClickListener(myListener)

then set myListener to do whatever you previously wanted to happen on the buttons onClick. Your activity will have to implement OnClickListener

Added bonus: you can make the images look like clouds :)

Post a Comment for "Android Animation - Button Stays Clickable"