• Android启动画面实现


    在应用程序中经常用到启动画面,会启动一个后台线程为主程序的运行准备资源。
    Android要实现启动画面可以这样做:
    这是splash.xml布局文件的代码[code]<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>[/code]

    放一个ImageView加载启动画面图片
    SplashActivity作为主视图启动[code]/** 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();
            }
            
        }[/code]

  • 相关阅读:
    汉语-词语:注重
    汉语-词语:解释
    汉语-词语:接受
    汉语-词语:专注
    汉语-词语:构想
    生物-植物-果树:枣树
    汉语-词语:维度
    汉语-词语:真传
    XML基础知识学习
    Java Swing界面编程(25)---事件处理:鼠标事件及监听处理
  • 原文地址:https://www.cnblogs.com/xiaochao1234/p/4226561.html
Copyright © 2020-2023  润新知