发布于 2017-07-19 01:38:18 | 121 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


这篇文章主要介绍了Android编程之简单启动画面实现方法,结合实例形式较为详细的分析了开机启动画面的制作步骤及布局、Activity跳转、权限控制等的相关操作技巧,需要的朋友可以参考下

本文实例讲述了Android简单启动画面实现方法。分享给大家供大家参考,具体如下:

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

1. splash.xml布局文件


<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秒后执行跳转到主视图


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


<?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>

PS:关于AndroidManifest.xml文件相关属性功能可参考本站在线工具:

希望本文所述对大家Android程序设计有所帮助。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务