ImageButton动画 [英] ImageButton animation

查看:123
本文介绍了ImageButton动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android中实现一本动画书,动画是由XML(不是Android XML)定义的.图像放置在固定位置,当用户触摸屏幕上的某个元素时,该应用会播放声音并为图像按钮设置动画,从而更改图像的src和位置(X和Y).

我想知道我该怎么做.由于图像点的大小不同,我认为

高达API 1的教程和支持库九个旧Androids

I am implementing a animated book in Android and the animations are defined by an XML (not an Android XML). The images are positioned in fixed positions and when user touches in a element on the screen, the app plays a sound and animate the imagebutton, changing the image src and positions (X and Y).

I want to know how can I do that. As images dot not have the same size, I think the sprites solution is not a good way to solve it.

Its like the image 2:

Thank you

解决方案

There are two types of animations:

View Animation and Proprety 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 dissadvantage of the View Animation is that it only change the position of where the View object is DRAWN. Phisically, it still stays in the same position. That's why the button is unclickable, 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 ViewAnimation

Tutorial and SupportLybrary up to API 1: Nine Old Androids

这篇关于ImageButton动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆