每个Android应用程序启动之后都会出现一个Splash启动界面,显示产品LOGO、公司LOGO或者开发者信息。如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段枯燥的时间,提高用户体验。

1.splash.xml布局文件

 1
2
3
4
5
6
7
8
9
10
11
12
13
<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"
tools:context=".SplashActivity" > <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/welcome_android"
android:scaleType="fitCenter" /> </RelativeLayout>

2.SplashActivity类,使用Handler的postDelayed方法,3秒后执行跳转到主视图

 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
package cn.eoe.leigo.splash;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler; /**
*
* @{#} SplashActivity.java Create on 2013-5-2 下午9:10:01
*
* class desc: 启动画面
*
* <p>Copyright: Copyright(c) 2013 </p>
* @Version 1.0
* @Author <a href="mailto:gaolei_xj@163.com">Leo</a>
*
*
*/
public class SplashActivity extends Activity { //延迟3秒
private static final long SPLASH_DELAY_MILLIS = 3000; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash); // 使用Handler的postDelayed方法,3秒后执行跳转到MainActivity
new Handler().postDelayed(new Runnable() {
public void run() {
goHome();
}
}, SPLASH_DELAY_MILLIS);
} private void goHome() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivity(intent);
SplashActivity.this.finish();
}
}

3.配置AndroidManifest.xml

 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
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.eoe.leigo.splash"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" /> <application
android:icon="@drawable/logo"
android:label="@string/app_name" >
<activity
android:name=".SplashActivity"
android:configChanges="keyboardHidden"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
</application> </manifest>

Android启动画面实现的更多相关文章

  1. 我的Android最佳实践之—— Android启动画面的实现方法

    本文实例讲述了Android启动画面的实现方法.分享给大家供大家参考.具体分析如下: 在应用程序中经常用到启动画面,会启动一个后台线程为主程序的运行准备资源.Android要实现启动画面可以这样做: ...

  2. Android 启动画面

    如果你的程序初始化时间过长,那么在初始化之前,程序会现实一个空白的activity页,十分难看. 添加一个启动画面的方法就是为响应的activity加入自定义的Theme,并在theme中设定 and ...

  3. 改动Android启动画面

    一.Android的启动步骤 1.启动Linux 2.载入Android 3.显示Android桌面 二.分析 Android载入开机动画的源代码文件是: /opt/android4.3/framew ...

  4. 简单设置android启动画面

    1.新建Activity,以及layout文件夹里的xml文件2.将新建Activity在AndroidManifest中设为默认Activity,并且添加:android:theme="@ ...

  5. android启动画面隐藏状态栏全屏显示

    1.在根部局给一个id,然后直接设置就行了layout.setSystemUiVisibility(View.INVISIBLE); 状态栏就没有了. 2.如果你只是想改变状态栏颜色的也可以 //5. ...

  6. android 之 启动画面的两种方法

    现在,当我们打开任意的一个app时,其中的大部分都会显示一个启动界面,展示本公司的logo和当前的版本,有的则直接把广告放到了上面.启动画面的可以分为两种设置方式:一种是两个Activity实现,和一 ...

  7. Android应用启动画面

    原文地址: [Android]应用启动画面 - 空客的日志 - 网易博客 http://blog.163.com/da7_1@126/blog/static/104072678201291921028 ...

  8. Android创建启动画面[转]

    每个Android应用启动之后都会出现一个Splash启动界面,显示产品的LOGO.公司的LOGO或者开发者信息.如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段枯燥 ...

  9. Android创建启动画面

    每一个Android应用启动之后都会出现一个Splash启动界面,显示产品的LOGO.公司的LOGO或者开发人员信息.假设应用程序启动时间比較长,那么启动界面就是一个非常好的东西,能够让用户耐心等待这 ...

随机推荐

  1. 脚本语言&& Performance Testing

    watin: http://www.cnblogs.com/dahuzizyd/archive/2007/04/13/ruby_on_rails_windows_instatnrails_study_ ...

  2. Word embedding

    https://en.wikipedia.org/wiki/Word_embedding 简言之,就是讲词汇或短语映射成实值特征向量.

  3. Hashing filters for very fast massive filtering

    If you have a need for thousands of rules, for example if you have a lot of clients or computers, al ...

  4. 转载:LBP的初步理解

    转自http://blog.csdn.net/ty101/article/details/8905394 本文的PDF版本,以及涉及到的所有文献和代码可以到下列地址下载: 1.PDF版本以及文献:ht ...

  5. form表单验证

    <script> $(document).ready(function(){ $('.pinglunform').submit(function(){ var issubmit = 0; ...

  6. 【渗透测试学习平台】 web for pentester -1.介绍与安装

    web for pentester是国外安全研究者开发的的一款渗透测试平台,通过该平台你可以了解到常见的Web漏洞检测技术. 官网:https://www.pentesterlab.com 下载地址: ...

  7. 前后台Json的转换

    jsp:JSON.stringify(params):params:表示数组 servlet:Store store = (Store) JSONObject.toBean(JSONObject.fr ...

  8. 統計數字(2007年NOIP全国联赛提高组)

    题目描述 Description [问题描述]某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*109).已知不相同的数不超过10000 个,现在需要统计这些自然数各自出现的 ...

  9. UVALive-7303 Aquarium (最小生成树)

    题目大意:在nxm的方格中,每一个1x1的小方格中都有一堵沿对角线的墙,并且每堵墙都有一个坚固程度,这些墙将nxm的方格分割成了若干个区域.现在要拆除一些墙,使其变成一个区域. 题目分析:将区域视作点 ...

  10. 越狱Season 1-Episode 12:Odd Man Out

    Season 1-Episode 12:Odd Man Out -Sorry to keep you waiting. 抱歉让你等了半天 -Oh, it's, uh, not a problem. 嗯 ...