Android帧动画
通过播放一张一张图片来实现一段动画
首先配置anim.xml:
1 <?xml version="1.0" encoding="utf-8"?> 2 <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> 3 4 <item android:drawable="@drawable/a" android:duration="200"/> 5 <item android:drawable="@drawable/b" android:duration="200"/> 6 <item android:drawable="@drawable/c" android:duration="200"/> 7 <item android:drawable="@drawable/d" android:duration="200"/> 8 <item android:drawable="@drawable/e" android:duration="200"/> 9 </animation-list>
然后用一个ImageView显示
1 <ImageView 2 android:id="@+id/iv" 3 android:layout_centerInParent="true" 4 android:onClick="click3" 5 android:clickable="true" 6 android:layout_width="200dp" 7 android:layout_height="200dp" />
再。。。。
1 public void click3(View v){ 2 ImageView iv = (ImageView)findViewById(R.id.iv); 3 iv.setBackgroundResource(R.drawable.anim); 4 AnimationDrawable ad = (AnimationDrawable)iv.getBackground(); 5 ad.start(); 6 }
就是这么简单。。。。
标签:
帧动画
, AnimationDrawable
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· dotnet 9 通过 AppHostRelativeDotNet 指定自定义的运行时路径
· 如何统计不同电话号码的个数?—位图法
· C#高性能开发之类型系统:从 C# 7.0 到 C# 14 的类型系统演进全景
· 从零实现富文本编辑器#3-基于Delta的线性数据结构模型
· 记一次 .NET某旅行社酒店管理系统 卡死分析
· 用c#从头写一个AI agent,实现企业内部自然语言数据统计分析
· 三维装箱问题(3D Bin Packing Problem, 3D-BPP)
· Windows上,10分钟构建一个本地知识库
· 使用 AOT 编译保护 .NET 核心逻辑,同时支持第三方扩展
· Java虚拟机代码是如何一步一步变复杂且难以理解的?