補間動畫與幀動畫

補間動畫Tween

alpha    rotate scale   translate  

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="3000"
    android:fillAfter="true"
    >
    <alpha
        android:fromAlpha="1.0"
        android:toAlpha="0.3"
        >
    </alpha>
    <rotate
        android:fromDegrees="0"
        android:toDegrees="720"
        android:pivotX="50%"
        android:pivotY="50%"
        >
    </rotate>
    <scale
        android:fromXScale="100%"
        android:toXScale="50%"
        android:fromYScale="100%"
        android:toYScale="150%"
        android:pivotX="50%"
        android:pivotY="50%"
        >
    </scale>
    <translate
        android:fromXDelta="0"
        android:toXDelta="50%"
        android:fromYDelta="0"
        android:toYDelta="50%"
        >
    </translate>
</set>

佈局動畫
LayoutAnimationController
<1>delay:動畫間隔時間
<2>order:動畫順序
<3>列表動畫

開源網址:(第三方動畫框架)http://blog.csdn.net/u013101864/article/details/51500136

幀動畫Frame

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.zking.administrator.g160628_android17_animation.FrameActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/iv_frame_image"
        android:background="@drawable/iv_frame"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="開始"
        android:onClick="start"
        />


</LinearLayout>
iv_frame.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="true"
    ><!-幀動畫的自動執行:oneshot  。 如果爲true,表示動畫只播放一次停止在最後一幀上,如果設置爲false表示動畫循環播放。--->
 <item android:drawable="@drawable/anim_0010001" android:duration="200"></item> 
<item android:drawable="@drawable/anim_0010002" android:duration="200"></item> <item android:drawable="@drawable/anim_0010003" android:duration="200"></item> <item android:drawable="@drawable/anim_0010004" android:duration="200"></item> <item android:drawable="@drawable/anim_0010005" android:duration="200"></item> <item android:drawable="@drawable/anim_0010006" android:duration="200"></item> <item android:drawable="@drawable/anim_0010007" android:duration="200"></item> <item android:drawable="@drawable/anim_0010008" android:duration="200"></item> <item android:drawable="@drawable/anim_0010009" android:duration="200"></item> <item android:drawable="@drawable/anim_0010010" android:duration="200"></item> <item android:drawable="@drawable/anim_0010011" android:duration="200"></item> <item android:drawable="@drawable/anim_0010012" android:duration="200"></item> <item android:drawable="@drawable/anim_0010013" android:duration="200"></item> <item android:drawable="@drawable/anim_0010014" android:duration="200"></item> <item android:drawable="@drawable/anim_0010015" android:duration="2000"></item> <item android:drawable="@drawable/anim_0010016" android:duration="200"></item> <item android:drawable="@drawable/anim_0010017" android:duration="200"></item></animation-list>

package com.zking.administrator.g160628_android17_animation;

import android.graphics.drawable.AnimationDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class FrameActivity extends AppCompatActivity {

    private ImageView iv_frame_image;
    private AnimationDrawable animationDrawable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_frame);
        iv_frame_image = (ImageView) findViewById(R.id.iv_frame_image);
        animationDrawable = (AnimationDrawable) iv_frame_image.getBackground();
    }
    public void start(View view){
        animationDrawable.start();
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章