Android启动画面的实现方法
更新时间:2015年01月19日 14:39:10 投稿:shichen2014
这篇文章主要介绍了Android启动画面的实现方法,分析了布局文件及加载启动文件的实现方法,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了Android启动画面的实现方法。分享给大家供大家参考。具体分析如下:
在应用程序中经常用到启动画面,会启动一个后台线程为主程序的运行准备资源。
Android要实现启动画面可以这样做:
这是splash.xml布局文件的代码:
复制代码 代码如下:
<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>
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作为主视图启动:
复制代码 代码如下:
/** 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();
}
}
@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();
}
}
希望本文所述对大家的Android程序设计有所帮助。
相关文章
Android UI设计系列之HTML标签实现TextView设置中文字体加粗效果(6)
这篇文章主要介绍了Android UI设计系列之使用HTML标签,实现在TextView中对中文字体加粗的效果,具有一定的实用性和参考价值,感兴趣的小伙伴们可以参考一下2016-06-06AndroidStudio重新share代码和上传到svn新地址教程
这篇文章主要介绍了AndroidStudio重新share代码和上传到svn新地址教程,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-04-04Android studio button 按钮 四种绑定事件的方法【实例代码】
这篇文章主要介绍了Android studio button 按钮 四种绑定事件的方法,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下2018-08-08
最新评论