36 Android Activity跳转动画 获取当前版本

package com.example.androd_activity_anim;

import junit.runner.Version;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {
	private Button button;
	private int myVerison;//版本信息

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		button=(Button)findViewById(R.id.button1);
		button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//获取当前版本信息
				myVerison=Integer.valueOf(android.os.Build.VERSION.SDK);
				if(myVerison > 11)
				{
					Toast.makeText(MainActivity.this, ">>>"+myVerison, 1).show();
					Intent intent=new Intent(MainActivity.this, other.class);
					startActivity(intent);
					overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
				}else{
					Toast.makeText(MainActivity.this, ">>>"+myVerison, 1).show();
				}
				
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}


 在res创建anim->zoomin.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:duration="300"
        android:fromXScale="0.1"
        android:fromYScale="0.1"
        android:pivotX="50%p"
        android:pivotY="50%p"
        android:toXScale="1.0"
        android:toYScale="1.0" />
    <!-- 这里为了看到动画演示效果,把动画持续时间设为3秒 -->
    <alpha
        android:duration="300"
        android:fromAlpha="0.1"
        android:toAlpha="1.0" />

</set>

zoomout.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:duration="300"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%p"
        android:pivotY="50%p"
        android:toXScale=".5"
        android:toYScale=".5" />
    <!--
系统内置的动画持续时间 
android:duration="@android:integer/config_mediumAnimTime" 

    -->
    <alpha
        android:duration="300"
        android:fromAlpha="1.0"
        android:toAlpha="0" />

</set>

 


你可能感兴趣的:(36 Android Activity跳转动画 获取当前版本)