1. 程式人生 > >歡迎界面旋轉進入

歡迎界面旋轉進入

ive lean per package ati pre stat 版本 int

技術分享圖片



<
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rl_welcome_root" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" tools:context
="${relativePackage}.${activityClass}" > <ProgressBar android:id="@+id/pb_welcome_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:layout_marginBottom
="50dp" android:indeterminateDrawable="@anim/image_progress" android:indeterminateDuration="700"/> <TextView android:id="@+id/tv_welcome_version" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal
="true" android:layout_above="@id/pb_welcome_loading" android:layout_marginBottom="10dp" android:text="當前版本: 1.0" android:textSize="20sp" /> </RelativeLayout>

image_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progess" >

</rotate>



public class WelcomeActivity extends Activity {

    private RelativeLayout rl_welcome_root;
    private Handler handler  = new Handler(){
        public void handleMessage(android.os.Message msg) {
            if(msg.what==1) {
                startActivity(new Intent(WelcomeActivity.this, SetupGuide1Activity.class));
                //關閉自己
                finish();
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        
        rl_welcome_root = (RelativeLayout) findViewById(R.id.rl_welcome_root);
        
        //顯示動畫
        showAnimation();
        
        //發送延遲3s的消息
        handler.sendEmptyMessageDelayed(1, 3000);
    }

    /**
     * 顯示動畫
     * 
     * 旋轉動畫  RotateAnimation: 0-->360 視圖的中心點 2s
     * 透明度動畫 AlphaAnimation: 0-->1 2s
     * 縮放動畫 ScaleAnimation: 0-->1 視圖的中心點 2s
     */
    private void showAnimation() {
        //旋轉動畫  RotateAnimation: 0-->360 視圖的中心點 2s
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360, 
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(2000);
        //透明度動畫 AlphaAnimation: 0-->1 2s
        AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
        alphaAnimation.setDuration(2000);
        //縮放動畫 ScaleAnimation: 0-->1 視圖的中心點 2s
        ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(2000);
        //創建復合動畫,並添加
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.addAnimation(rotateAnimation);
        animationSet.addAnimation(alphaAnimation);
        animationSet.addAnimation(scaleAnimation);
        //啟動
        rl_welcome_root.startAnimation(animationSet);
    }
}

歡迎界面旋轉進入