Android之七  闪屏的实现


可以有两种方法实现:


:在主文件中写入


<span style="font-size:14px;">  // 取消标题  
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);  
        // 取消状态栏  
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  </span>



二:可以在AndroidManifest.xml配置文件中修改显示的状态

在application应用程序中加入


<span style="font-size:14px;"> <activity  android:name="com.example.walkerlogin1.WelcomeActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            >
       
         </activity></span>



下面是具体 的实现代码:

package com.example.walkerlogin1;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.RelativeLayout;


public class WelcomeActivity extends Activity {

	protected void onCreate(Bundle savedInstanceState) {   
		super.onCreate(savedInstanceState);  
             // 取消标题  
             this.requestWindowFeature(Window.FEATURE_NO_TITLE);  
        // 取消状态栏  
           this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  
		setContentView(R.layout.activity_welcome);  
		RelativeLayout layoutWelcome=(RelativeLayout) findViewById(R.id.activity_welcome);  
		AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f);   
		alphaAnimation.setDuration(3000);   
		layoutWelcome.startAnimation(alphaAnimation);  
		alphaAnimation.setAnimationListener(new AnimationListener() {    
			public void onAnimationStart(Animation animation) { 

			}      

			public void onAnimationRepeat(Animation animation) { 

			}     

			public void onAnimationEnd(Animation animation) { 
				System.out.println("你好");
				Intent  intent=new Intent(WelcomeActivity.this,GuideActivity.class);     
				startActivity(intent);  
			} 
		});  
	}
}


也可以在配置文件中修改

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.walkerlogin1"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
      
        <activity  android:name="com.example.walkerlogin1.MainActivity"
            android:label="@string/app_name"></activity>
         <activity  android:name="com.example.walkerlogin1.WelcomeActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            >
             <intent-filter>
                <action android:name="android.intent.action.MAIN" />//取消标题栏

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter> 
       
         </activity>
         
    </application>

</manifest>


UI布局代码:activity_welcome.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"
    android:background="@drawable/welcome_bg"
    tools:context=".WelcomeActivity" 
    android:id="@+id/activity_welcome">

</RelativeLayout>


最终显示界面:

Android之七  闪屏的实现_闪屏的源码