转自http://blog.csdn.net/nmsoftklb/article/details/12943483

1、当你打开一个应用程序时,总会看到前面有一个加载动画页面,下面我们就看看怎么来实现 

2、新建一个.xml 文件,添加一个ImageView 组件,该组件用来加载图片

[html] view plaincopyprint?
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     tools:context=".MainActivity" >  
  6.   
  7.     <ImageView   
  8.         android:id="@+id/welcome_img"  
  9.         android:layout_width="match_parent"  
  10.         android:layout_height="match_parent"  
  11.         />  
  12.   
  13. RelativeLayout>  

3、创建一个Activity,用来启动与实现渐变效果

[java] view plaincopyprint?

package com.example.activity;    import android.app.Activity;  import android.content.Intent;  import android.os.Bundle;  import android.view.animation.AlphaAnimation;  import android.view.animation.Animation;  import android.view.animation.Animation.AnimationListener;  import android.widget.ImageView;    public class MainActivity extends Activity {      private ImageView welcomeImg = null;        @Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);          welcomeImg = (ImageView) this.findViewById(R.id.welcome_img);          AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f);          anima.setDuration(3000);// 设置动画显示时间          welcomeImg.startAnimation(anima);          anima.setAnimationListener(new AnimationImpl());        }        private class AnimationImpl implements AnimationListener {            @Override          public void onAnimationStart(Animation animation) {              welcomeImg.setBackgroundResource(R.drawable.welcome);          }            @Override          public void onAnimationEnd(Animation animation) {              skip(); // 动画结束后跳转到别的页面          }            @Override          public void onAnimationRepeat(Animation animation) {            }        }        private void skip() {          startActivity(new Intent(this, OtherActivity.class));          finish();      }  }  


更多相关文章

  1. AdapterViewFlipper实现跑马灯横幅广告滚动效果
  2. android 桌面小组件小记
  3. Android学习笔记八:基本视图组件:CheckBox
  4. 垮平台开发平台
  5. Android(安卓)UI 之 获取组件或者元素的坐标
  6. Animation & Property Animation 使用
  7. 【Android】Webview常见问题
  8. Android常用动画Animation的使用
  9. android 点击效果动画增强

随机推荐

  1. C语言进阶(二)--- 整型存放练习
  2. 【DB笔试面试732】在Oracle中,Oracle Clus
  3. C语言实现计算器
  4. C语言编程笔试题(一)
  5. C语言数据的存储-上
  6. 【DB笔试面试645】在Oracle中,当收集表的
  7. 【DB笔试面试494】Oracle中哪个包用于生
  8. C语言之结构体内存的对齐
  9. C语言数据的存储-下
  10. C语言编程入门训练(二)