package com.ray.bubble;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnTouchListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
public class BubbleExplosion extends Activity {
private FrameLayout fl;
private ExplosionView exv1;
private AnimationDrawable exa1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set full screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
WindowManager.LayoutParams. FLAG_FULLSCREEN);
fl = new FrameLayout(this);
fl.setBackgroundResource(R.drawable.bg);
exv1 = new ExplosionView(this);
exv1.setVisibility(View.INVISIBLE);
exv1.setBackgroundResource(R.anim.explosion);
exa1 = (AnimationDrawable)exv1.getBackground();
fl.addView(exv1);
fl.setOnTouchListener(new LayoutListener());
setContentView(fl);
}
class ExplosionView extends ImageView{
public ExplosionView(Context context) {
super(context);
}
//handle the location of the explosion
public void setLocation(int top,int left){
this.setFrame(left, top, left+40, top+40);
}
}
class LayoutListener implements OnTouchListener{
public boolean onTouch(View v, MotionEvent event) {
//first u have to stop the animation,or if the animation
//is starting ,u can start it again!
exv1.setVisibility(View.INVISIBLE);
exa1.stop();
float x = event.getX();
float y = event.getY();
exv1.setLocation((int)y-20, (int)x-20);
exv1.setVisibility(View.VISIBLE);
exa1.start();
return false;
}
}
}
android气泡动画实现
5星 · 超过95%的资源 需积分: 33 199 浏览量
2012-01-04
12:09:58
上传
评论 3
收藏 164KB RAR 举报
huyuanzhi
- 粉丝: 0
- 资源: 2
最新资源
- 基于CarNet实现裂缝检测python源码+文档说明+数据+图片(课程设计)
- 课程设计-基于耐火材料裂缝剥落检测python源码+课件
- 基于OpenCV的视频道路车道检测python源码+文档说明+实验演示+图片+使用方法(高分毕业设计)
- 基于OpenCV的案例:图像边缘、角点和轮廓检测,图像分割,图像增强;图片拼接;运动目标检测,颜色直方图比较,三帧帧差法,抠图
- SmartPlug-html大一笔记
- SmartPlug-proteusdemo
- Preliminary Findings on Handmade Rattan Baby Crib andBassinet Designs Regarding.zip
- aveebfq_v1.2.83_downyi.com.apk
- 基于有机发光二极管(OLED)的建模优化算法的matlab仿真源码+数据+文档说明+项目说明(高分课程设计)
- hash01-test.c 本人哈希表(一)的示例代码,仅供参考!
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页