Android-01-渐变动画效果,展示启动屏,取消标题,取消状态栏,也即全屏

Android-01-渐变动画效果,展示启动屏,取消标题,取消状态栏,也即全屏


package com.jiangge.yiweibo;

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

public class AppStart extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);//取消标题
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //取消状态栏,也即全屏
		setContentView(R.layout.logo);
		
		//渐变动画效果,展示启动屏
		ImageView imageLogo = (ImageView) findViewById(R.id.img_logo);
		AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
		animation.setDuration(2000);
		imageLogo.setAnimation(animation);
		animation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {}
			@Override
			public void onAnimationRepeat(Animation animation) {}
			@Override
			public void onAnimationEnd(Animation animation) {
				redirectTo(); //动画结束时跳转
			}
		});
	}

	private void redirectTo(){
		Intent intent = new Intent(AppStart.this, LoginActivity.class);
		startActivity(intent);
	}
}



注:

		requestWindowFeature(Window.FEATURE_NO_TITLE);//取消标题
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //取消状态栏,也即全屏
		setContentView(R.layout.logo);

取消标题,取消状态栏 需要写在setContentView()方法前面。


渐变动画效果,会在动画结束时跳转到另一个Activity页面。




File: layout/logo.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:background="@drawable/main_bg"
    android:gravity="center"
    android:orientation="vertical" >
    
	<ImageView 
	    android:id="@+id/img_logo"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:src="@drawable/logo_bg"/>
</LinearLayout>



注:

android:background="@drawable/main_bg"

android:src="@drawable/logo_bg"





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值