Android UI:动画:帧动画

文章目录

定义

按顺序展示不同的图片

两种创建方式

代码:直接创建对象

XML:加载动画文件,创建对象

xml文件在res/drawable/目录下,使用R.drawable.xxx获取

API

动画类

AnimationDrawable

Drawable的子孙类​​​​​​​
操作

绑定ImageView

View.setBackground(R.drawable.xxx)

ImageView.setImageResource(R.drawable.xxx)​​​​​​​

启动动画

AnimationDrawable.start()
AnimationDrawable的start()方法不能在Activity的onCreate方法中调用,因为此时AnimationDrawable还未完全附着到window上,
最好的调运时机是在onWindowFocusChanged()方法中

总结

相关推荐
.豆鲨包16 分钟前
【Android】Binder机制浅析
android·binder
Nerve2 小时前
GooglePay: API 文档
android·google
Nerve2 小时前
GooglePay: 订阅商品购买流程
android·google
summerkissyou19872 小时前
Audio-触摸音-播放流程
android
Nerve2 小时前
GooglePay: 消耗商品购买流程
android·google
LiteHeaven3 小时前
Android 8.1 Unable to create application data 问题分析
android
Nerve3 小时前
GooglePay: 一个基于 Google Play Billing Library 封装的 Android 支付库
android·google
Nerve3 小时前
Google Play 结算系统入门指南
android·google
测试界茜茜4 小时前
独立搭建UI自动化测试框架分享
自动化测试·软件测试·功能测试·程序人生·ui·职场和发展
青莲8434 小时前
Android Jetpack - 2 ViewModel
android·前端