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"