首先我们新建一个名为welcome 的android project ,在create activity这里选择Fullscreen Activity 像这样
在drawable里面上传上我们的qq欢迎图片
建完android项目后 我们修改layout1文件为
<FrameLayout 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" android:background="@drawable/welcome" tools:context=".FullscreenActivity" > </FrameLayout>
package com.example.welcome; import com.example.welcome.util.SystemUiHider; import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.MotionEvent; import android.view.View; /** * An example full-screen activity that shows and hides the system UI (i.e. * status bar and navigation/system bar) with user interaction. * * @see SystemUiHider */ public class FullscreenActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fullscreen); } }
package com.example.welcome; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.layout); } }
不要忘记在AndroidManifest.xml声明一下MainActivity
<activity android:name=".MainActivity" ></activity>
layout文件中创建一个xml布局如下
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是qq主程序" android:layout_gravity="center_horizontal" /> </LinearLayout>
代码如下
package com.example.welcome; import com.example.welcome.util.SystemUiHider; import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.MotionEvent; import android.view.View; /** * An example full-screen activity that shows and hides the system UI (i.e. * status bar and navigation/system bar) with user interaction. * * @see SystemUiHider */ public class FullscreenActivity extends Activity { private int START_ACTIVITY=0x1; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fullscreen); //3秒后跳转到MainActivity页面 handler.sendEmptyMessageDelayed(START_ACTIVITY, 3000); } private Handler handler=new Handler(){ public void handleMessage(android.os.Message msg) { switch(msg.what){ case 0x1: startActivity(new Intent(FullscreenActivity.this,MainActivity.class)); } }; }; }
android:theme="@android:style/Theme.Black.NoTitleBar"现在就OK了 可以在手机上运行一下