转载自:http://smallmaple.iteye.com/blog/1255120

欢迎界面实现有多种方法,目前了解的实现方法包括

1) Animation;

2) 线程实现;

3) Handle实现;

本例子讨论第一种方法,第二种目前已经了解,但是第三种还不了解。

虽然是转载,但是源代码不全也不详细,可能有些人还是看不到最终处理结果,

这个代码包含了所有的代码和xml文件。

1. 创建名为WelcomeDemo的项目,Activity的对应名称为WelcomeDemoActivity;

2. 在res下创建anim目录,并创建文件welcome_alpha.xml;

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/accelerate_interpolator"> 
    <alpha   
        android:fromAlpha="0.0" 
        android:toAlpha="1.0" 
        android:duration="2000"   
        /> 
    <alpha   
        android:fromAlpha="1.0" 
        android:toAlpha="0.0" 
        android:startOffset="3000"
        android:duration="3000"   
        /> 
</set>

3. 在WelcomeDemoActivity.java下的代码如下:

package zcping.hello.Welcomedemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class WelcomeDemoActivity extends Activity implements AnimationListener {
    /** Called when the activity is first created. */
    private ImageView  imageView = null;  
    private Animation alphaAnimation = null;  
      
    @Override 
    protected void onCreate(Bundle savedInstanceState) {  
          
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.welcome);  
        imageView = (ImageView)findViewById(R.id.welcome_image_view);  
        alphaAnimation = AnimationUtils.loadAnimation(this, R.anim.welcome_alpha);  
        alphaAnimation.setFillEnabled(true); //启动Fill保持  
        alphaAnimation.setFillAfter(true);  //设置动画的最后一帧是保持在View上面  
        imageView.setAnimation(alphaAnimation);  
        alphaAnimation.setAnimationListener(this);  //为动画设置监听  
    }
    @Override 
    public void onAnimationStart(Animation animation) {  
          
    }  
      
    @Override 
    public void onAnimationEnd(Animation animation) {  
        //动画结束时结束欢迎界面并转到软件的主界面  
        Intent intent = new Intent(this, MainActivity.class);  
        startActivity(intent);  
        this.finish();  
    }  
      
    @Override 
    public void onAnimationRepeat(Animation animation) {  
          
    }  
      
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) {  
        //在欢迎界面屏蔽BACK键  
        if(keyCode==KeyEvent.KEYCODE_BACK) {  
            return false;  
        }  
        return false;  
    }    
}

4. 创建MainActiviy.java文件用于创建主程序,作为调用欢迎界面后的主程序。

package zcping.hello.Welcomedemo;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

5. 对应于MainActivity.java的XML文件如下main.xml;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>

6.  对应于WelcomeDemoActivity.java的XML文件welcome.xml如下:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"   
    android:gravity="center_vertical|center_horizontal"> 
    <ImageView 
        android:id="@+id/welcome_image_view"   
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:src="@drawable/welcome" 
        /> 
</LinearLayout>

7. 把欢迎界面welcome_image_view.png的图片放到drawable目录下。

运行结果如下:

源码可联系:QQ 99597951

用Animation动画实现Android应用的欢迎界面相关推荐

  1. 【Android 基础】Animation 动画介绍和实现

    转载自:http://www.cnblogs.com/yc-755909659/p/4290114.html 1.Animation 动画类型 Android的animation由四种类型组成: XM ...

  2. 【Android 基础】Animation 动画介绍和实现(转载)

    最近做了下这方面的研究,在博客园上找到了一片很好很详细的文章,于是转了一下.原地址是http://www.cnblogs.com/yc-755909659/p/4290114.html 1.Anima ...

  3. Animation动画概述和执行原理

    动画入门和进阶文章列表: Animation动画概述和执行原理 Android动画之补间动画TweenAnimation Android动画之逐帧动画FrameAnimation Android动画之 ...

  4. Animation动画相关

    本文出自http://wangstar.javaeye.com/blog/409115,感觉基础知识归纳得不错,就COPY下来方便查找. 动画效果编程基础--Android Animation     ...

  5. android中设置Animation 动画效果

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  6. Android Animation动画效果简介

    AlphaAnimation 淡入淡出动画  <alpha>A fade-in or fade-out animation. Represents an AlphaAnimation. a ...

  7. Android动画开发——Animation动画效果

    动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面 ...

  8. Android Animation动画(很详细)

    Animations 一.Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行旋转.缩放.淡入淡出等, ...

  9. Android Property Animation动画

    3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中又引入了一个新的动画系统:property animation,这三 ...

最新文章

  1. iptables防火墙的基本配置
  2. Entity Framework 出现 此 ObjectContext 实例已释放,不可再用于需要连接的操作 的错误...
  3. 卡尔曼滤波器原理和matlab实现
  4. Java学习笔记3——集合框架
  5. 阿里巴巴Java开发手册——速读记录
  6. 本月与上月对比数据叫什么_动态轨控数据分析:2019-11
  7. Bluetooth篇 开发实例之六 蓝牙RSSI计算距离
  8. 应用架构步入“无服务器”时代 Serverless技术迎来新发展
  9. D 语言是否可作为入门级的编程语言?
  10. 什么是python基础教程-python基础教程之python是什么?概念解析
  11. 常用网络协议的端口号
  12. CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
  13. xampp配置虚拟主机的步骤
  14. python电影网络爬虫代码_Python爬虫——爬取豆瓣电影Top250代码实例
  15. 为新版本火狐安装去广告插件
  16. python基础_字典_列表_元组考试
  17. 大厂成熟Foc电机代码STM32f031C6. 把原先的原理图,给整理了
  18. Python:通过网络爬虫实现一个简易控制台音乐播放器
  19. 数据科学之matplotlib库
  20. openwrt各软件包对应功能_极路由 1 刷 openwrt记录

热门文章

  1. (006)网络编程,反射及其应用,MySQL数据库
  2. win10打开软件总是弹出用户帐户控制怎么办
  3. Kubernetes各版本对应支持的docker版本列表
  4. Ubuntu打开VirtualBox的VDI(Virtual Disk Image)文件
  5. vue组件之间传值的几种方式
  6. vue组件之间的传值的几种方法
  7. php 执行慢,怎么查询php哪执行得慢
  8. centos下unzip命令不可用
  9. flex array java_Flex中ArrayCollection 与java中的ArrayList互转
  10. WRF-hydro,WRF,WPS安装2