Focus on technology, enjoy life!—— QQ:804212028
浏览链接:http://blog.csdn.net/y18334702058/article/details/44624305
- 主题:用户界面之Splash(闪屏启动)
-
用Splash做闪屏启动界面(实例):
实现效果:
APP启动全屏显示一张背景图片,2s后跳转到MainActivity。
AndroidManifest.xml:
(在AndroidManifest中使用android:[email protected]:[email protected]?屏显示。再在定义第一个Activity启动为SplashActivity)
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.demo2" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <activity android:name="com.example.demo2.SplashActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.demo2.MainActivity"> </activity> </application></manifest>
splash.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:background="@drawable/a2" ></LinearLayout>
splash.xml中涉及的图片资源a2:
SplashActivity.java:
(实现定时2s跳转)
package com.example.demo2;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.widget.Button;public class SplashActivity extends Activity { Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); new Handler().postDelayed(new Runnable(){ @Override public void run() { // TODO Auto-generated method stub Intent intent = new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); finish(); } }, 2000); }}
Focus on technology, enjoy life!—— QQ:804212028
浏览链接:http://blog.csdn.net/y18334702058/article/details/44624305