1、登录步骤
Logo ----> Login -----> Main
2、代码
2.1 Logo的实现
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white" android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/fscreen"
>
<ImageView
android:id="@+id/logo_bg"
android:src="@drawable/logo_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Code:
package com.itcast.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
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;
/**
* 欢迎页
* @author tomatos.to
*
*/
public class LogoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 全屏显示
// 1.去标题
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 2.全屏设置
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.log);
ImageView iv = (ImageView) findViewById(R.id.logo_bg);
// 设置淡入淡出的动画效果
AlphaAnimation aa = new AlphaAnimation(0.1f, 1.0f);
// 设置动画的持续时间为3s
aa.setDuration(3000);
// 开始播放动画
iv.startAnimation(aa);
// 当动画执行完后,启动LoginActivity
aa.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
Intent it = new Intent(LogoActivity.this, LoginActivity.class);
startActivity(it);
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
});
}
}
本文介绍了一款Android应用启动时的Logo展示动画实现方法。通过使用AlphaAnimation来达到淡入淡出的效果,并在动画结束后自动跳转到登录界面。
1303

被折叠的 条评论
为什么被折叠?



