Step by step _ Android development course [31] _ User Interface Splash (pop-up) and _ androidsplash

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.