在android中gif的效果和渐变效果
来源:互联网 发布:c语言程序代码大全 编辑:程序博客网 时间:2024/05/23 22:43
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/aa" android:duration="300"></item> <item android:drawable="@drawable/bb" android:duration="300"></item> <item android:drawable="@drawable/cc" android:duration="300"></item> <item android:drawable="@drawable/dd" android:duration="300"></item> <item android:drawable="@drawable/ee" android:duration="300"></item> <item android:drawable="@drawable/ff" android:duration="300"></item> </animation-list>
oneshot是为了设置一次动画 还是多次动画,true就是一次执行后就停止。
下面的代码就是在imageview中写入drawable中的xml,即上面的代码。
setContentView(R.layout.frame);btn = (Button) findViewById(R.id.button1);iv=(ImageView) findViewById(R.id.imageView1);iv.setImageResource(R.drawable.frame_anim);animationDrawable =(AnimationDrawable) iv.getDrawable();btn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubif(animationDrawable.isRunning())animationDrawable.stop();animationDrawable.start();}});
渐变效果:
在res下建文件夹 anim,然后在下面建alpha_anim.xml,
<?xml version="1.0" encoding="utf-8"?><alpha xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromAlpha="1" android:repeatCount="3" android:repeatMode="restart" android:toAlpha="0" ></alpha>
setContentView(R.layout.frame);btn = (Button) findViewById(R.id.button1);iv=(ImageView) findViewById(R.id.imageView1);//iv.setImageResource(R.drawable.frame_anim);animationDrawable =(AnimationDrawable) iv.getDrawable();btn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubAnimation animation =AnimationUtils.loadAnimation(FrameActivity.this, R.anim.alpha_anim);//给iv设置一个图片iv.setImageResource(R.drawable.aa);//iv开始播放动画iv.startAnimation(animation);}});
1 0
- 在android中gif的效果和渐变效果
- android中Button背景渐变效果和点击效果
- Android中Shape的渐变效果
- Android中渐变效果的设置
- Android中渐变效果的设置
- android实现文字渐变效果和歌词进度的效果
- android实现文字渐变效果和歌词进度的效果
- LinearGradient在android开发中实现字体渐变效果实例
- Android Button 中绚丽渐变效果的设置 如此简单。。。
- Android Button 中绚丽渐变效果的设置 如此简单。。。
- android中使用shader实现渐变效果
- Android Shader渐变效果
- Android的实现文字渐变效果和歌词进度的效果
- android ListView的overscroll(模糊渐变效果)
- Android的button颜色渐变效果:
- Android的TitleBar实现透明度渐变效果
- Android开机Activity的渐变效果
- ios中做出颜色渐变的效果
- git乱码解决方案汇总
- Android Studio安装插件
- 堆排序java版
- php构造函数的继承方法
- View 样式(背景色、圆角、描边、等等)
- 在android中gif的效果和渐变效果
- Spring入门第二个例子
- 224,GCD多线程
- 如何分析解决Android ANR
- hadoop 中 HDFS 由于多次格式化引起的 nanenode 与 datanode 启动异常
- java注解annotation的解释
- Android开发学习总结(一)——搭建最新版本的Android开发环境
- 个人主页
- 表的分段