对刚才设置好的内容做一下整理:
配置欢迎界面的xml:
layout创建下start.xml
start.xml内容:
<?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"
android:gravity="bottom"
android:background="@drawable/start_background">
</LinearLayout>
开发 android:background="@drawable/start_background"使用文件
在drawable下创建start_background.xml
start_background.xml内容:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:scaleType="fitStart"
android:src="@drawable/view480_800" />
创建StartActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
public class StartActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final View view=View.inflate(this, R.layout.start, null);
setContentView(view);
AlphaAnimation alphaAnimation=new AlphaAnimation(0.3f, 1.0f);
alphaAnimation.setDuration(2000);
view.startAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
Intent intent=new Intent();
intent.setClass(StartActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
});
}
}
最后设置AndroidManifest.xml
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="StartActivity"
android:label="@string/app_name" android:theme="@android:style/Theme.Holo.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MainActivity"></activity>
</application>
完成!