• Android -- 逐帧动画


    在处理耗时工作的时候,大多数会弹出一个加载的框,里面有一个连续旋转的图片,很多时候都是用一张图片,使用rotate来设定旋转,不过看起来不太美观,没有形象感,在3.0之前Android有两种动画效果分别是补间动画和帧动画,用一张图片实现的是使用补间动画,定义给出两个关键帧,通过一些算法将给定属性值在给定的时间内在两个关键帧间渐变。

    动画布局                                                                                    

    <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <item
            android:drawable="@drawable/appstore"
            android:duration="200"/>
        <item
            android:drawable="@drawable/calculator"
            android:duration="200"/>
        <item
            android:drawable="@drawable/camera"
            android:duration="200"/>
        <item
            android:drawable="@drawable/clock"
            android:duration="200"/>
        <item
            android:drawable="@drawable/compass"
            android:duration="200"/>
        <item
            android:drawable="@drawable/contacts"
            android:duration="200"/>
        <item
            android:drawable="@drawable/facetime"
            android:duration="200"/>
        <item
            android:drawable="@drawable/game_center"
            android:duration="200"/>
        <item
            android:drawable="@drawable/itunes_store"
            android:duration="200"/>
        <item
            android:drawable="@drawable/mail"
            android:duration="200"/>
    
    </animation-list>

    代码                                                                                          

    public class MainActivity extends Activity {
    
        private ImageView iv;
        private AnimationDrawable ani;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            iv = (ImageView) findViewById(R.id.iv);
            iv.setBackgroundResource(R.drawable.ic_list);
            ani = (AnimationDrawable) iv.getBackground();
        }
    
        public void click(View view) {
            ani.start();
        }
    
    }

    我是天王盖地虎的分割线                                                                

    1

    源代码:http://pan.baidu.com/s/1dD1Qx01

    帧动画.zip

    转载请注明出处:http://www.cnblogs.com/yydcdut

  • 相关阅读:
    [Mise] Refetch API data when a state value changes with the `$watch` property in Alpine JS
    Android之用自定义的shape去实现shadow效果
    http抓包以及网速限定
    ios成长之每日一遍(day 7)
    ios成长之每日一遍(day 6)
    ios成长之每日一遍(day 5)
    ios成长之每日一遍(day 4)
    ios成长之每日一遍(day 3)
    ios成长之每日一遍(day 2)
    ios成长之每日一遍(day 1)
  • 原文地址:https://www.cnblogs.com/yydcdut/p/3829613.html
Copyright © 2020-2023  润新知