android 开启动画(超首)

效果图:

为了录制效果配置为渐隐了。和主activity放在一块的话,当主activity被系统回收之后再次回到主activity时会再次执行onCreate,但开启动画一般只是第一次进入应用时执行一次,在应用里面不应该再次出现。因此单独使用了一个activity来做超首开启动画的特效,主要是使用了alpha动画特效

主要代码:

frist_main.xml

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/ivOpenImage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/open_bg2"
        android:src="@drawable/open_bg" />

</LinearLayout>


first_alpha.xml

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:toAlpha="1.0" />

</set>


FirstActivity

 

 

 

 

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

/**
 * 开启动画
 * 
 * @author qhg
 * @date 2014年3月4日
 * 
 */

public class FirstActivity extends Activity {
	private ImageView imageView;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏

		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);// 去掉信息栏
		setContentView(R.layout.frist_main);

		// 监听动画完成之后启动MainActivity
		Animation animation = AnimationUtils.loadAnimation(this,
				R.anim.first_alpha);
		animation.setFillAfter(true);
		imageView = (ImageView) findViewById(R.id.ivOpenImage);
		imageView.startAnimation(animation);
		animation.setAnimationListener(new MyAnimationListener());
	}
	
	/**
	 * 监听开启动画
	 * 
	 * @author Administrator
	 * 
	 */
	class MyAnimationListener implements AnimationListener {
		public void onAnimationStart(Animation animation) {

		}

		/**
		 * 动画结束时打开MainActivity,释放FirstActivity
		 */
		public void onAnimationEnd(Animation animation) {
			Intent intent = new Intent();
			intent.setClass(FirstActivity.this, MainActivity.class);
			startActivity(intent);
			//释放FirstActivity
			FirstActivity.this.finish();
		}

		public void onAnimationRepeat(Animation animation) {

		}

	}
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值