Android中FrameAnimation动画的使用

public void frameAnimation() throws FileNotFoundException {TextView mTextView = (TextView) findViewById(R.id.tv);mTextView.setBackgroundResource(R.drawable.frame);//把xml中设置好的帧动画资源设置给控件AnimationDrawable animDrawable = (AnimationDrawable) mTextView.getBackground();//得到该控件的背景Drawable对象Bitmap bitmap = BitmapFactory.decodeStream(new FileInputStream(Environment.getExternalStorageDirectory() + "/Download/aaa.jpg"));//在代码中动态添加背景图,也可以从服务器获取到的输入流动态添加animDrawable.addFrame(new BitmapDrawable(null, bitmap), 2000);//设置持续时间animDrawable.setAlpha(180);//设置图片的透明度animDrawable.setOneShot(false);//设置是否只运行一次,设置为true为循环运行animDrawable.start();}这样注释上也说清楚了,可以通过xml文件添加图片也可以通过代码来动态添加。

,生活不会永远都困难;祝你爱情蜜甜,事业大进步

Android中FrameAnimation动画的使用

相关文章:

你感兴趣的文章:

标签云: