Android启动画面 Android启动画面的实现方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Android启动画面 Android启动画面的实现方法

  2021-03-21 我要评论
想了解Android启动画面的实现方法的相关内容吗,在本文为您仔细讲解Android启动画面的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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>

放一个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();
        }
}

希望本文所述对大家的Android程序设计有所帮助。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们