一.创建欢迎界面

来源:互联网 发布:买mac还是ipad 编辑:程序博客网 时间:2024/06/05 06:07

初学Android,根据项目来学习,挑了一个综合性稍强的项目,新浪微博客户端,主要是来调用新浪微博的接口,界面效果之类的自己写。


不想说过多的废话了,直接来上项目了,今天主要来写欢迎动画的效果。


欢迎动画,主要是一张带logo的图片,停留3秒,跳到主界面。


首先写xml布局文件


activity_logo.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent">    <ImageView        android:id="@+id/logo"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:src="@drawable/logo"        android:scaleType="fitXY" /></LinearLayout>
LogoActivity.java

package com.xq.zgsweibo.welcome;import com.xq.zgsweibo.R;import com.xq.zgsweibo.R.id;import com.xq.zgsweibo.R.layout;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;public class LogoActivity extends Activity {ImageView LogoImageView;@Overrideprotected 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.activity_logo);LogoImageView = (ImageView) findViewById(R.id.logo);Animation animation = new AlphaAnimation(0.0f, 1.0f);//从AlphaAnimation拿到animation  淡入淡出效果animation.setDuration(3000);//设置动画延时时间animation.setAnimationListener(new AnimationListener() {//动画监听public void onAnimationStart(Animation animation) {//动画开始时候的操作}public void onAnimationRepeat(Animation animation) {//动画重复时的操作}public void onAnimationEnd(Animation animation) {// 动画结束时候的操作Intent intent = new Intent(LogoActivity.this,LoginActivity.class);startActivity(intent);}});LogoImageView.setAnimation(animation);//设置动画}}

要点:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏setContentView(R.layout.activity_logo);
-------------------------------------------------------------------------------

Animation animation = new AlphaAnimation(0.0f, 1.0f);//从AlphaAnimation拿到animation  淡入淡出效果animation.setDuration(3000);//设置动画延时时间animation.setAnimationListener(new AnimationListener() {//动画监听public void onAnimationStart(Animation animation) {//动画开始时候的操作}public void onAnimationRepeat(Animation animation) {//动画重复时的操作}public void onAnimationEnd(Animation animation) {// 动画结束时候的操作Intent intent = new Intent(LogoActivity.this,LoginActivity.class);startActivity(intent);}});LogoImageView.setAnimation(animation);//设置动画



0 0