Android 引导页面

来源:互联网 发布:网络维护人员 编辑:程序博客网 时间:2024/05/17 07:19

Loading.java


package com.tax;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.Window;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.Animation.AnimationListener;import android.widget.ImageView;public class Loading extends Activity {ImageView loading_img;public static Loading loading_instance = null;protected void onCreate(Bundle savedInstanceState) {requestWindowFeature(Window.FEATURE_NO_TITLE);super.onCreate(savedInstanceState);loading_instance = this;setContentView(R.layout.loading);loading_img = (ImageView) findViewById(R.id.loading_new);/* * An animation listener receives notifications from an animation. * Notifications indicate animation related events, such as the end or * the repetition of the animation. */AlphaAnimation animation = new AlphaAnimation(1.0f, 1.0f);// 设置透明度(0.0f,// 1.0f)渐变效果animation.setDuration(2000);// 设置动画时间毫秒loading_img.setAnimation(animation);animation.setAnimationListener(new AnimationListener() {@Overridepublic void onAnimationStart(Animation animation) {}@Overridepublic void onAnimationRepeat(Animation animation) {}@Overridepublic void onAnimationEnd(Animation animation) {//跳转到主界面Intent intent = new Intent(Loading.this, MainFragment.class);startActivity(intent);}});}}

Android 引导页面 ,启动应用后在引导页面停留指定时间后跳转到主界面。

比较简单不多说了!

loading.xml

<RelativeLayout 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/loading_new"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:adjustViewBounds="true"        android:scaleType="fitXY"        android:src="@drawable/loading" /></RelativeLayout>




0 0
原创粉丝点击