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

【android笔记】android程序启动界面的编写

2014-10-19 23:05 169 查看
作为入门菜鸟在这里卡顿了一小下,最后得到了解决,也对android中的activity机制有了一个初步的认识。

下面是我在这部分的代码编写与笔记:
Splash.java
public class Splash extends Activity {

private static final int LOAD_DISPLAY_TIME = 1500;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);

setContentView(R.layout.splash);

new Handler().postDelayed(new Runnable() {
public void run() {
/* Create an Intent that will start the Main WordPress Activity. */
Intent mainIntent = new Intent(Splash.this, MainActivity.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, LOAD_DISPLAY_TIME); //1500 for release

}

}

saplsh.xml

<?xml version="1.0" encoding="utf-8"?>
<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="centerCrop"
android:src="@drawable/splash">
</ImageView>

</LinearLayout>
AndroidManifest.xml

<activity android:name=".Splash"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<span style="background-color: rgb(255, 102, 102);"> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /></span>
</intent-filter>
</activity>其中标红的两行为将该activity设置为android应用程序启动activity。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android xml 启动界面