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();// 开启动画
            }
        });
  • 相关阅读:
    PHP中获取当前页面的URL信息
    $_POST和$GLOBALS['HTTP_RAW_POST_DATA'] 的区别
    curl模拟ip和来源进行网站采集的实现方法
    mysql修改root密码的几种方法
    微信小程序实现支付功能
    git获取远程服务器的指定分支
    mysql函数技巧整理
    sql 查询目标数据库中所有的表以其关键信息
    SET NOCOUNT ON
    C# CultureInfo中常用的InvariantCulture
  • 原文地址:https://www.cnblogs.com/yegong0214/p/6277750.html
Copyright © 2011-2022 走看看