Question

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 set to -100dp. From that position they start falling down untill they get lost on the bottom side of the screen.

The thing is, I need those buttons to be clickable, during the process of animation.

So far, I found some documentation about how I can make the buttons clickable AFTER the animation ends. But I don't need that. I need to be able to click on the buttons through the animation time itself.

NOTE: I need something that works with versions before 3.0.

Anybody has any link to documentation or some example or anything ?

Was it helpful?

Solution

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

OTHER TIPS

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top