您的位置:首页 > 移动开发

APP进去时的welcome界面

2016-01-14 18:42 399 查看
定义一个activity,然后推迟两秒再跳转到主activity上。

布局中:

<LinearLayout 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"
tools:context="zhangli.newsapp.WelcomeActivity">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/welcome"/>
</LinearLayout>


代码:
package zhangli.newsapp.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import zhangli.newsapp.MainActivity;
import zhangli.newsapp.R;

public class WelcomeActivity extends Activity {

private final long SPLASH_LENGTH = 2000;

//导入这个包import android.os.Handler;
Handler handler = new Handler();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
handler.postDelayed(new Runnable() {  //使用handler的postDelayed实现延时跳转

public void run() {
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_LENGTH);//2秒后跳转至应用主界面MainActivity
}
}


最好是在androidMainfest配置全屏。

在activity下:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: