Android应用程序启动之后需要一个Splash启动界面,显示产品LOGO、公司LOGO等等,提高用户体验。

1.splash.xml布局文件

 1 2 3 4 5 6 7 8 910111213
 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" >            android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="@drawable/welcome_android"        android:scaleType="fitCenter" />

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

 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940414243
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:   启动画面 * * 

Copyright: Copyright(c) 2013

* @Version 1.0 * @Author Leo * * */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 9101112131415161718192021222324252627282930
<?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>
 到这里并没有完事,我遇到一个小问题,那就是我项目中的页面需要导航条,但是我启动页肯定要全屏显示的,所以,我需要在启动页面去掉导航条

这样在启动页中this.requestWindowFeature(Window.FEATURE_NO_TITLE);这样就达到了启动图全屏显示了




更多相关文章

  1. Android(安卓)7.0 SystemUI(1)--启动过程
  2. AbstractProcessor注解处理器
  3. 编译android源码6---运行android编译源码
  4. Android(安卓)系统服务 - PMS 的启动过程
  5. Android(安卓)系统状态栏一体化
  6. Android(安卓)Adapter详解
  7. Android在开机时自动启动一个应用程序
  8. android音乐播放器Service的生命周期分析
  9. android 自定义ratingbar 图片显示不全的解决方案

随机推荐

  1. GitHub上面非常受欢迎的android开源项目
  2. 为什么开发人员更喜欢iOS而非Android
  3. Android开发工程师面试心得
  4. adb connect --通过WiFi连接android设备
  5. 我学院手把手教你学Android(案例篇)
  6. Android实现通用的ActivityGroup(效果类似
  7. Android下的横向ListView源代码下载
  8. 用Eclipse开发Android应用程序(1): 开始
  9. android内置数据库的一个错误解决方案:Can
  10. android解析xml文件的方式(其二)