安卓欢迎界面创建

欢迎界面实现有多种方法,目前了解的实现方法包括(Animation、线程实现、Handle实现)

下面介绍我常用的一种:

首先是欢迎界面的布局.这里就用图片一张:

<?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" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ff0000"
        android:keepScreenOn="true"
        android:src="@drawable/wel" />

</LinearLayout>

然后是欢迎界面的activity:
package com.example.welcome;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
/**
 * 本页主要实现欢迎界面的功能
 */
 
public class AppWelcomActivity extends Activity {
	private static final int INTENT = 1;
	private Boolean TOUCH_F = false;
	
	private Handler handler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case INTENT:
			Intent intent = new Intent(AppWelcomActivity.this, MainActivity.class);
			startActivity(intent);
			onDestroy();
				break;
			}
		};
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
		WindowManager.LayoutParams.FLAG_FULLSCREEN);
		this.setContentView(R.layout.app_start_view);
		Message message = new Message();
		message.what = INTENT;
		handler.sendMessageDelayed(message,2000);
	}
	@Override
	protected void onDestroy() {
		finish();
		super.onDestroy();
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			TOUCH_F = false;
		}
		return true;
	}
}
最后修改AndroidManifest配置文件,把AppWelcomActivity设置成默认:
<activity
            android:name="com.example.welcome.AppWelcomActivity"
            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="MainActivity" android:theme="@style/AppBaseTheme"></activity>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值