Android Animation - Button stays clickable
Asked Answered
S

2

2

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 ?

Somnifacient answered 20/8, 2013 at 10:56 Comment(0)
S
3

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

Somnifacient answered 29/8, 2013 at 11:3 Comment(0)
R
0

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

Roundhouse answered 20/8, 2013 at 11:1 Comment(2)
It makes no difference. The thing is, the animation changes the position where the button, or any other view, is drawn...not it's phisical location.Somnifacient
oh. You can make the animations another way, with a timer so that every certain amount of milliseconds the views layout parameters are actually changed. That will probably work.Roundhouse

© 2022 - 2024 — McMap. All rights reserved.