android 启动画面实现Frame动画

效果图如下:

android 启动画面实现Frame动画_第1张图片









以下是logo.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:background="@drawable/logo_bg">
	<LinearLayout
		android:layout_height="wrap_content"
		android:gravity="center"
		android:layout_alignParentBottom="true"
		android:layout_width="fill_parent">
	</LinearLayout>
	<ImageView
		android:scaleType="fitCenter"
		android:layout_height="wrap_content"
		android:layout_width="wrap_content"
		android:id="@+id/progress"
		android:layout_below="@+id/textView2"
		android:layout_centerHorizontal="true"></ImageView>
	<TextView
		android:id="@+id/textView2"
		android:layout_height="wrap_content"
		android:textSize="22dp"
		android:text="Loading..."
		android:textColor="#ffffff"
		android:layout_width="wrap_content"
		android:layout_centerVertical="true"
		android:layout_centerHorizontal="true"></TextView>
</RelativeLayout>




<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:duration="150" android:drawable="@drawable/loading00" />
    <item android:duration="150" android:drawable="@drawable/loading01" />
    <item android:duration="150" android:drawable="@drawable/loading02" />
    <item android:duration="150" android:drawable="@drawable/loading03" />
    <item android:duration="150" android:drawable="@drawable/loading04" />
    <item android:duration="150" android:drawable="@drawable/loading05" />
    <item android:duration="150" android:drawable="@drawable/loading06" />
    <item android:duration="150" android:drawable="@drawable/loading07" />
    <item android:duration="150" android:drawable="@drawable/loading08" />
    <item android:duration="150" android:drawable="@drawable/loading09" />
    <item android:duration="150" android:drawable="@drawable/loading10" />
    <item android:duration="150" android:drawable="@drawable/loading11" />
</animation-list>




实现动画的效果代码:

	
	void init() {
		progress = (ImageView) findViewById(R.id.progress);
		animDrawable = (AnimationDrawable) getResources().getDrawable(R.anim.loading_gif);
		aas = new AlphaAnimation(1.0f, 1.0f);
		aas.setDuration(4000);
		progress.setAnimation(aas);

	}

	private class AnimAlpha implements AnimationListener {
		@Override
		public void onAnimationStart(Animation animation) {
			progress.setBackgroundResource(R.anim.loading_gif);
			Object background = progress.getBackground();
			animDrawable = (AnimationDrawable) background;
			animDrawable.start();

		}

		@Override
		public void onAnimationRepeat(Animation animation) {
		}

		@Override
		public void onAnimationEnd(Animation animation) {
			Intent it = new Intent(Logo.this, MainActivity.class);
			startActivity(it);
			animDrawable.stop();
			Logo.this.finish();
		}
	}



你可能感兴趣的:(android 启动画面实现Frame动画)