zoukankan      html  css  js  c++  java
  • Android中帧动画的创建

    帧动画,实质上就是快速播放多张连接效果的图片,现在一般可用于下拉刷新时候的headView

    实现步骤:

      1、首先应该准备一组连接效果的图片

      2、在res>drawable目录下创建xml文件,将图片对象添加到集合naimation-list

    <?xml version="1.0" encoding="utf-8"?>
        <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
            android:oneshot="false">
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_01"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_02"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_03"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_04"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_05"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_06"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_07"
                android:duration="200"/>
            <item android:drawable="@mipmap/bga_refresh_mt_refreshing_08"
                android:duration="200"/>
        </animation-list>

        注意: android:oneshot="false" 设置false表示可以循环播放 设置true表示只播放一次

      3、加载进ImageView背景进行播放

    final ImageView image= (ImageView) findViewById(R.id.image);
        image.setBackground(R.drawable.refresh);
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AnimationDrawable animationDrawable= (AnimationDrawable) image.getBackground();
                animationDrawable.start();// 开启动画
            }
        });
  • 相关阅读:
    function与感叹号
    js中的|| 与 &&
    [转] html屏蔽右键、禁止复制
    ExtJS 5.1 WINDOW BLUR
    ExtJS 网页版执行工具
    Excel 随即获得一组数据集中的数据
    [转] Spring Data JPA Tutorial: Pagination
    Set up eclipse for Ext js and spket IDE plugin
    ExtJS Alias, xtype and widget
    ExtJS stores
  • 原文地址:https://www.cnblogs.com/yegong0214/p/6277750.html
Copyright © 2011-2022 走看看