androidが開発したアニメーションActivity

10702 ワード

Androidの開発では、少し修正すれば、システムは私たちのために良いアニメーション効果を設計しました.
いくつかの非常にcoolの効果を実現することができる.今日はActivityの2つのアニメーション効果をご紹介します.
一つはalphia変換効果、もう一つは増幅効果である.
------------------------------------------------------------------
package jack.animation.activity;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class AnimationActivity extends Activity{    private Button btnFadeIn;    private Button btnZoomIn;    @Override    public void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        btnFadeIn = (Button) findViewById(R.id.Button01);        btnFadeIn.setOnClickListener(onFadeInClick);        btnZoomIn = (Button) findViewById(R.id.Button02);        btnZoomIn.setOnClickListener(onZoomInClick);    }    private OnClickListener onFadeInClick = new OnClickListener()    {        @Override        public void onClick(View v)        {            startActivity(new Intent(AnimationActivity.this, AniOneActivity.class));            overridePendingTransition(R.anim.fade, R.anim.hold);        }    };    private OnClickListener onZoomInClick = new OnClickListener()    {        @Override        public void onClick(View v)        {            startActivity(new Intent(AnimationActivity.this, AniOneActivity.class));            overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);        }    };}
------------------------------------------------------------------
package jack.animation.activity;



import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;



public class AniOneActivity extends Activity

{

    private Button btn;



    @Override

    protected void onCreate(Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.ani_activity);

        btn = (Button) findViewById(R.id.BtnClose);

        btn.setOnClickListener(onBtnCloseClick);

    }



    private OnClickListener onBtnCloseClick = new OnClickListener()

    {

        @Override

        public void onClick(View v)

        {

            finish();

        }

    };

}
---------------------------fade.xml---------------------------------
<?xml version="1.0" encoding="utf-8"?>



<alpha xmlns:android="http://schemas.android.com/apk/res/android"

    android:interpolator="@android:anim/accelerate_interpolator"

    android:fromAlpha="0.0" android:toAlpha="1.0"

    android:duration="@android:integer/config_longAnimTime" />
--------------------------hold.xml----------------------------------
<?xml version="1.0" encoding="utf-8"?> 



<translate xmlns:android="http://schemas.android.com/apk/res/android"

       android:interpolator="@android:anim/accelerate_interpolator"

       android:fromXDelta="0" android:toXDelta="0"

       android:duration="@android:integer/config_longAnimTime" />
-----------------------------zoom_enter.xml------------------------
<?xml version="1.0" encoding="utf-8"?>



<set xmlns:android="http://schemas.android.com/apk/res/android"

        android:interpolator="@android:anim/decelerate_interpolator">

    <scale android:fromXScale="2.0" android:toXScale="1.0"

           android:fromYScale="2.0" android:toYScale="1.0"

           android:pivotX="50%p" android:pivotY="50%p"

           android:duration="@android:integer/config_mediumAnimTime" />

</set>
-----------------------------zoom_exit.xml----------------------------
<?xml version="1.0" encoding="utf-8"?>



<set xmlns:android="http://schemas.android.com/apk/res/android"

        android:interpolator="@android:anim/decelerate_interpolator"

        android:zAdjustment="top">

    <scale android:fromXScale="1.0" android:toXScale=".5"

           android:fromYScale="1.0" android:toYScale=".5"

           android:pivotX="50%p" android:pivotY="50%p"

           android:duration="@android:integer/config_mediumAnimTime" />

    <alpha android:fromAlpha="1.0" android:toAlpha="0"

            android:duration="@android:integer/config_mediumAnimTime"/>

</set>