Animation(2、帧动画)
16lz
2021-01-25
android帧动画相对简单,只是将资源中的图片文件依据一定规则播放,类似GIF文件。
首先定义ani.xml,如下:
<?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/aboutdlg_logo" android:duration="500"/> <item android:drawable="@drawable/actionbar_logo" android:duration="500"/> <item android:drawable="@drawable/aboutdlg_logo" android:duration="500"/> <item android:drawable="@drawable/actionbar_logo" android:duration="500"/></animation-list>
然后进行调用:
public class MainActivity extends Activity { private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView)findViewById(R.id.image); imageView.setBackgroundResource(R.anim.ani); AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground(); animationDrawable.start(); }}
更多相关文章
- 一款常用的 Squid 日志分析工具
- GitHub 标星 8K+!一款开源替代 ls 的工具你值得拥有!
- RHEL 6 下 DHCP+TFTP+FTP+PXE+Kickstart 实现无人值守安装
- Linux 环境下实战 Rsync 备份工具及配置 rsync+inotify 实时同步
- unity实现android虚拟现实应用
- ProgressBar自定义样式中的层叠图片显示问题
- 自定义ViewGroup获取子View参数
- init 分析2
- android > ListView > 加载res图标