1、两个Activity:
首先是AndroidManifest.xml
<a target=_blank href="http://app918.com"><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sunshine.splash"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" ;android:label="@string/app_name"> ;
<activity android:name=".Splash"
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="Main">
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest></a>
<a target=_blank href="http://app918.com">package net.hlovey.splash;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splash extends Activity {
private final int SPLASH_DISPLAY_LENGHT = 3000; //延迟三秒
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
Intent mainIntent = new Intent(Splash.this,Main.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
}
}</a>
androidmanifest.xml就不多说了。先看布局代码:
<a target=_blank href="http://app918.com"><?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
<LinearLayout android:id=”@+id/splashscreen” android:orientation=”vertical”
android:layout_width=”fill_parent” android:layout_height=”fill_parent”>
<ImageView android:layout_width=”wrap_content”
android:layout_height=”wrap_content” android:src=”@drawable/splash”
android:layout_gravity=”center”
android:layout_marginTop=”130px”/>
<TextView
android:id=”@+id/info”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:gravity=”center”
android:paddingTop=”10px”
android:text=”This is a splash!!”/>
</LinearLayout>
<WebView android:id=”@+id/browser”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent” android:layout_weight=”1″/>
</LinearLayout></a>
有一个id为splashscreen 的linearlayout,是程序启动时显现的部分。id为browser是程序的主界面显示部分。
private WebView webView;
private Handler mHandler = new Handler();
private Animation myAnimation_Alpha;
private Animation animatinoGone ;