1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package wht.android.loading;
 
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ImageView;
 
public class LoadingView extends ImageView implements Runnable
{
        private boolean isStop = false;
         
        private int[] imageIds;
        private int index = 0;
        private int length = 1;
         
        public LoadingView(Context context)
        {
                this(context, null);
        }
 
        public LoadingView(Context context, AttributeSet attrs)
        {
                super(context, attrs);
        }
         
        public void setImageIds(int[] imageId)
        {
                this.imageIds = imageId;
                if(imageIds != null && imageIds.length > 0)
                {
                        length = imageIds.length;
                }
        }
         
                @Override
        protected void onDetachedFromWindow()
        {
                // TODO Auto-generated method stub
                super.onDetachedFromWindow();
                isStop = true;
        }
 
        @Override
        protected void onDraw(Canvas canvas)
        {
                // TODO Auto-generated method stub
                super.onDraw(canvas);
                if(imageIds != null && imageIds.length > 0)
                {
                        this.setImageResource(imageIds[index]);
                }
        }
 
        @Override
        public void run()
        {
                while(!isStop)
                {
                        index = ++index % length;
                        postInvalidate();
                        try
                        {
                                Thread.sleep(400);
                        }
                        catch (InterruptedException e)
                        {
                                e.printStackTrace();
                        }
                }
        }
         
        public void startAnim()
        {
                new Thread(this).start();
        }
 
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package wht.android.loading;
 
import android.app.Activity;
import android.os.Bundle;
 
public class MainActivity extends Activity
{
     
    private LoadingView main_imageview;
     
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        main_imageview = (LoadingView)findViewById(R.id.main_imageview);
        initLoadingImages();
         
        new Thread()
        {
            @Override
            public void run()
            {
                main_imageview.startAnim();
            }
        }.start();
         
    }
     
    private void initLoadingImages()
    {
        int[] imageIds = new int[6];
        imageIds[0] = R.drawable.loader_frame_1;
        imageIds[1] = R.drawable.loader_frame_2;
        imageIds[2] = R.drawable.loader_frame_3;
        imageIds[3] = R.drawable.loader_frame_4;
        imageIds[4] = R.drawable.loader_frame_5;
        imageIds[5] = R.drawable.loader_frame_6;
         
        main_imageview.setImageIds(imageIds);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:background="#e1e1e1">
        <wht.android.loading.LoadingView
                android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
                android:id="@+id/main_imageview" android:src="@drawable/loader_frame_1"
                android:layout_marginTop="190dp" android:layout_width="wrap_content"
                ></wht.android.loading.LoadingView>
 
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="启动中..."
        android:layout_marginTop="10dip"
        android:textColor="#666666"
        android:layout_gravity="center_horizontal"
        android:textSize="20sp"
/>
</LinearLayout>

Android 启动界面的实现(转载)的更多相关文章

  1. android启动界面

    /**  * 应用程序启动类:显示欢迎界面并跳转到主界面  * <a href="http://my.oschina.net/arthor" target="_bl ...

  2. $Android启动界面(Splash)的两种实现方法

    (一)用2个Activity实现 用Handler对象的postDelayed方法来实现延迟跳转的目的. 补充:Handler的常用方法: // 立即执行Runnable对象 public final ...

  3. Android 启动界面的制作

    直接看实例吧 package com.example.textview; import android.app.Activity; import android.content.Intent; imp ...

  4. Android 设置启动界面

    启动界面的意义是为了让后台处理耗时的复杂工作,当工作处理完成后,即可进入主界面.相比让用户等待布局加载完成,使用一张图片作为启动背景,会带来更好的体验. 首先,需要建立一个简单的布局: <?xm ...

  5. Android(java)学习笔记162:Android启动过程(转载)

    转载路径为: http://blog.jobbole.com/67931/ 1. 关于Android启动过程的问题: 当按下Android设备电源键时究竟发生了什么? Android的启动过程是怎么样 ...

  6. Android应用--新浪微博客户端新特性滚动视图和启动界面实现

    新浪微博客户端新特性滚动视图和启动界面实现 2013年8月20日新浪微博客户端开发之启动界面实现 前言: 使用过新浪微博客户端的童鞋都清楚,客户端每一次升级之后第一次启动界面就会有新特性的介绍,用户通 ...

  7. Android 启动APP时黑屏白屏的三个解决方案(转载)

    你会很奇怪,为什么有些app启动时,会出现一会儿的黑屏或者白屏才进入Activity的界面显示,但是有些app却不会如QQ手机端,的确这里要做处理一下.这里先了解一下为什么会出现这样的现象,其实很简单 ...

  8. Android开发(25)--framebyframe帧动画并实现启动界面到主界面的跳转

    Drawable animation可以加载Drawable资源实现帧动画.AnimationDrawable是实现Drawable animations的基本类.推荐用XML文件的方法实现Drawa ...

  9. 在AndroidManifest.xml文件中设置Android程序的启动界面方法

    从网上搜集了一堆的Android代码,比如Android的Login程序和Android的Helloworld程序,但是却总不能正确运行一个正确的程序,郁闷了很久,终于在一次一次的测试后成功的在And ...

随机推荐

  1. Node.js monly图片批量下载爬虫1.00

    此爬虫又用到了iconv转码,代码如下: //====================================================== // mmonly图片批量下载爬虫1.00 ...

  2. docker学习笔记二:常用命令

    docker学习笔记二:常用命令 查看docker常用命令 docker --help 返回结果如下: 其中常用的命令如下: 1.image相关操作 展示所有的image: 删除image: rmi ...

  3. 使用python在WEB页面上生成EXCEL文件

    来自:http://blog.sina.com.cn/s/blog_5d18f85f0101bxo7.html 近日写的一个程序需要在WEB服务器上生成EXCEL文件供用户下载,研究了一下找到了以下比 ...

  4. ASP.NET请求管道、应用程序生命周期、整体运行机制

    我们知道在ASP.NET中,若要对ASP.NET应用程序进行 初始化并使它处理请求,必须执行一些处理步骤,熟悉应用程序生命周期非常重要,这样才能在适当的生命周期阶段编写代码,达到预期的效果.永远不要做 ...

  5. Chrome Dev Editor:一个新的JavaScript和Dart IDE

    在Google IO 2014期间,一位Google工程师带来了Chrome Dev Editor(CDE).该IDE用于创建面向桌面和移动设备的Chrome应用程序和Web应用程序.CDE支持Jav ...

  6. 【小程序】微信小程序开发—弹出框

    1. <span style="font-family:Comic Sans MS;font-size:18px;color:#333333;"><view cl ...

  7. mybatis学习知识

    目录 1,目录 2,介绍 3,快速入门 4,配置XML 5,xml文件映射 6,动态sql 7,java api 8,Statement Builders 9,日志 1,介绍 1.1 介绍 1.1.1 ...

  8. Name与x:Name的关系

    小序:   如果想用Google搜包含冒号的内容怎么办?比如我想搜x:Name这个字符串…… 原来,应该是这样——x::Name 这世道,连搜索也要加转义,全民程序员,要不要人活了?   正文:   ...

  9. 大规模分布式数据处理平台Hadoop的介绍 一种可靠、高效、可伸缩的处理方案

    http://www.nowamagic.net/librarys/veda/detail/1767 Hadoop是什么 Hadoop原来是Apache Lucene下的一个子项目,它最初是从Nutc ...

  10. linux c++ 文件获取md5

    当前在linux系统下,shell命令可以获取md5值,如下: 如果进行c++编程,在代码里执行shell命令可以获得,但是很不雅观,特别是了解了system或者popen函数的机制之后.现在介绍使用 ...