在屏幕中的效果(左上很小的那个,其他都是背景图):
先看动画实现代码explosion.xml(explosion意思是爆发) 手指点击后产生泡泡的动画是5张40*40的图片顺序播放产生的,每张持续时间为70毫秒,播放模式为oneshot,即一次。
BubbleExplosion.java 精华提炼:
1.Line 31 exv1.setBackgroundResource(R.anim.explosion);
exv1是继承自ImageView的视图,看到他将一个animation设置成背景了,惊讶!原来动画可以设置为背景图。
2.Line 32 exa1 = (AnimationDrawable)exv1.getBackground();
Line 60 exa1.start();
不仅仅Aniamtion有start()方法,原来AnimationDrawable作为一个Drawable的子类也可以有start()方法哦。
没见过吧,之前我也没见过;见过啦?我现在也见过了!
再补充几个常识性的
3. setContentView(fl);
用代码绘制布局,完全没用到layout/main.xml~~
4.Line 23-25
设置全屏
链接:点击打开链接