zoukankan      html  css  js  c++  java
  • android 开发之动画Activity

    在android开发中,系统已经为我们设计了一些很好的动画效果,只要我们稍作修改,

    就可以实现一些非常cool的效果.今天我给大家介绍的是Activity的两个动画效果,

    一个是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>
     
     
     
     
     
     
  • 相关阅读:
    Code Forces Gym 100886J Sockets(二分)
    CSU 1092 Barricade
    CodeChef Mahesh and his lost array
    CodeChef Gcd Queries
    CodeChef GCD2
    CodeChef Sereja and LCM(矩阵快速幂)
    CodeChef Sereja and GCD
    CodeChef Little Elephant and Balance
    CodeChef Count Substrings
    hdu 4001 To Miss Our Children Time( sort + DP )
  • 原文地址:https://www.cnblogs.com/sun_catboy/p/1720814.html
Copyright © 2011-2022 走看看