现在的位置: 首页 > 综合 > 正文

Android程序的启动画面制作

2013年10月14日 ⁄ 综合 ⁄ 共 2053字 ⁄ 字号 评论关闭

参考博客:http://blog.csdn.net/chaijun0613/article/details/6531262


今天晚上,我又做了一下开始没有了解清楚的Android程序的启动画面制作。附件是我的演示程序。

具体分析如下:
不管是哪个工程,只要你创建两个文件splash.xm 和 splash.java Activity 并且在Manifest定义首先启动的是splash.java Activity 。就可以了。然后就是在splash.java文件中写具体的操作了。下面是我的这几个文件的源代码。
splash.xml:
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="fill_parent" 
  android:layout_width="fill_parent" 
  android:orientation="vertical">
<ImageView android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
android:scaleType="fitCenter" 
android:src="@drawable/ico1">  这个是获取图片,在res/drawable/下的ico1.png文件
</ImageView>
</LinearLayout>
splash.java:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splash extends Activity{
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        Handler x = new Handler();
        x.postDelayed(new splashhandler(), 2000); //延时2秒
        
    }
    class splashhandler implements Runnable{
        public void run() {
            startActivity(new Intent(getApplication(),HelloAndroidActivity.class));  //其中HelloAndroidActivity是你要进入的下一个Activity
            Splash.this.finish(); 
        }
        
    }
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.helloandroid"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloAndroidActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="Splash">
         <intent-filter>
                <action android:name="android.intent.action.MAIN" />   作为主Activity入口
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

抱歉!评论已关闭.