Step by step _ Android development course [31] _ User Interface Splash (pop-up) and _ androidsplash
Focus on technology, enjoy life! -- QQ: 804212028.
Link: http://blog.csdn.net/y18334702058/article/details/44624305
- Topic: Splash on the user interface)
-
Use Splash to start the screen (Instance ):
Effect:
When the APP is started, a background image is displayed in full screen. After 2 seconds, it jumps to MainActivity.
AndroidManifest. xml:
(Android: theme = "@ android: style/Theme. NoTitleBar. Fullscreen" is used in AndroidManifest to define the topic to be displayed in full screen without a title bar. Start the first Activity as a 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>
Image resources a2 in splash. xml:
SplashActivity. java:
(Scheduled 2 S jump)
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.
Link: http://blog.csdn.net/y18334702058/article/details/44624305