Android启动画面实现
2013-08-02 12:38
323 查看
第一种方法:
启动界面作为主Activity的layout,一定时间后,启动另一个正式工作的Activity,进入工作界面;
这是splash.xml布局文件的代码
[xhtml] view
plaincopy
<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="fitCenter" android:src="@drawable/splash"></ImageView>
</LinearLayout>
放一个ImageView加载启动画面图片
SplashActivity作为主视图启动
[java] view
plaincopy
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),MainActivity.class));
SplashActivity.this.finish();
}
}
加载后使用Handler的postDelayed方法,2秒后执行跳转到主视图。
另一种方法:
在原来的工作layout上增加一个全屏的LinearLayout,注意,原来的工作界面跟在下面,原来怎样就怎样,一段时间后,隐藏这个全屏的LinearLayout,工作界面就自然而然显示出来了。
启动界面作为主Activity的layout,一定时间后,启动另一个正式工作的Activity,进入工作界面;
这是splash.xml布局文件的代码
[xhtml] view
plaincopy
<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="fitCenter" android:src="@drawable/splash"></ImageView>
</LinearLayout>
放一个ImageView加载启动画面图片
SplashActivity作为主视图启动
[java] view
plaincopy
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),MainActivity.class));
SplashActivity.this.finish();
}
}
加载后使用Handler的postDelayed方法,2秒后执行跳转到主视图。
另一种方法:
在原来的工作layout上增加一个全屏的LinearLayout,注意,原来的工作界面跟在下面,原来怎样就怎样,一段时间后,隐藏这个全屏的LinearLayout,工作界面就自然而然显示出来了。
相关文章推荐
- Android启动画面实现
- Android启动画面实现
- Android简单实现启动画面的方法
- 如何正确实现Android启动屏画面的方法(避免白屏)
- Android启动画面实现
- Android启动画面实现
- Android启动画面实现
- Android启动画面实现
- android 启动画面实现Frame动画
- Android启动画面实现
- Android启动画面实现
- Android启动画面的实现方法
- [转]Android启动画面实现
- Android应用启动画面实现
- Android启动画面实现
- Android启动画面实现
- android程序启动画面实现
- Android应用开发小随笔——应用启动画面屏的实现
- Android启动画面实现
- Android启动画面实现