Android 用Animation-list实现逐帧动画_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:42:06
原创
1494人浏览过

我们要实现的效果

准备资源文件放到res/drawable文件下中


light01.png

light02.png

light03.png

编写loading.xml 放到res/drawable

<!-- animation-list :根标签 oneshot :代表着是否只展示一遍,设置为false会不停的循环播放动画 android :duration 表示该图片的动画时长 -->  <?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/light01" android:duration="50"/>    <item  android:drawable="@drawable/light02" android:duration="50"/>    <item  android:drawable="@drawable/light03" android:duration="50"/></animation-list>
登录后复制

在activity_main.xml布局文件中,这样写

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">    <ImageView android:id="@+id/main_img_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5px" android:src="@drawable/loading"/>     <Button android:id="@+id/main_bt_start" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5px" android:text="开始" />    <Button android:id="@+id/main_bt_stop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5px" android:text="停止" /></LinearLayout>
登录后复制

在Activity中这样来写

bt_start.setOnClickListener(new OnClickListener()      {      @Override      public void onClick(View v) {      //获取 AnimationDrawable        animationDrawable = (AnimationDrawable) animationIV.getDrawable();          //开始动画        animationDrawable.start();      }  });   bt_stop.setOnClickListener(new OnClickListener()  {      @Override      public void onClick(View v) {     //获取 AnimationDrawable         animationDrawable = (AnimationDrawable) animationIV.getDrawable();         //停止动画         animationDrawable.stop();      }  });  
登录后复制

有兴趣的童鞋可以关注我的Blog,我的专栏会持续更新Android Studio 权威教程,以及2015 I/O大会上的NDK的配置和编译,我也全部会分享给大家。
并且我收到了CSND 的讲师邀请,后期我会把这些Android Studio的使用教程录制成视频。

来画数字人直播
来画数字人直播

来画数字人自动化直播,无需请真人主播,即可实现24小时直播,无缝衔接各大直播平台。

来画数字人直播 0
查看详情 来画数字人直播
/** * -------------- * 欢迎转载 | 转载请注明 * -------------- * 如果对你有帮助,请点击|顶| * -------------- * 请保持谦逊 | 你会走的更远 * -------------- * @author zsl * @github https://github.com/yy1300326388 * @blog http://blog.csdn.net/yy1300326388 */
登录后复制

版权声明:本文为博主原创文章,未经博主允许不得转载。

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号