【android笔记】android程序启动界面的编写
2014-10-19 23:05
169 查看
作为入门菜鸟在这里卡顿了一小下,最后得到了解决,也对android中的activity机制有了一个初步的认识。
下面是我在这部分的代码编写与笔记:
Splash.java
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。
下面是我在这部分的代码编写与笔记:
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开发笔记】3.编写第一个Android程序
- Android入门之第一个程序编写与启动
- Android笔记之:App应用之启动界面SplashActivity的使用
- 编写一个单文档界面的应用程序,程序启动后在用户区显示一个圆,用鼠标可以拖动这个圆。
- 安卓在AndroidManifest.xml文件中设置Android程序的启动界面方法
- android 程序启动界面的短暂黑屏解决办法
- [Android开发笔记]-----做一个启动界面
- 大灰狼汇编视频的启动程序编写的笔记
- Android开发笔记--制作启动界面splash
- Android 设置程序先启动登录界面 再启动主界面
- Android开发笔记--制作启动界面splash
- android 程序启动界面
- Android笔记之:App应用之启动界面SplashActivity的使用
- Android中Activity启动模式详解,可以控制程序按home键后进来还会调用一个自己不喜欢的界面
- Android初学者笔记(二)编写运行第一个程序
- Android使用配置文件,去掉程序启动界面的短暂黑屏
- 在AndroidManifest.xml文件中设置Android程序的启动界面方法
- 在AndroidManifest.xml文件中设置Android程序的启动界面方法
- Android使用主题配置文件,去掉程序启动界面的短暂黑屏。
- Android 入门笔记2--启动界面SplashActivity