zoukankan      html  css  js  c++  java
  • android 启动界面

    在启动一个app时常会有一个启动界面,在ios中直接设置lunch image就行了。不过在android想要实现这种效果就需要代码人为的设置啦。思路也很简单,在启动View只有一张图,让其自己休眠2秒左右的时间,然后跳进mianActivity的主界面就可以了。看代码:

    lunch.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="fitXY"
            android:src="@drawable/lunch">
        </ImageView>
    </LinearLayout>

    lunchView.java

    package com.gdou.gxk;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    
    
    public class LunchView extends Activity{
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.lunch);
            Handler x = new Handler();
            x.postDelayed(new lunchhandler(), 2000);
            
        }
        
        class lunchhandler implements Runnable{
    
            public void run() {
                startActivity(new Intent(getApplication(),LogInView.class));
                LunchView.this.finish();
            }
            
        }
    }

    其中的logInView就是我的程序的主界面啦,这样就有了如iphone的lunch image的效果,单纯只为效果而已。

    最后要注意在你的配置文件AndroidManifest中要把初始界面改成lunchView的。这样就行啦!!!

    update:

     由于项目中需要lunchView之后的logInView有判断(如果数据库有保存用户的话直接跳转到相关的内容)。这时候就有问题啦,出现了在跳转到内容界面之前会logIn的会先出现,闪一下。(我的判断是在LoginView的OnCreate中判断的)。在模拟器运行时,又是1.6的没有这种情况,2.2  4.0 的都有这种情况。

    最终没办法,找不出像iphone的在view出来前就做的方法,只能放弃上面所说的方法,采用另外一种给为巧妙的方法:

    即lunchImage放在loginView中,只要一张覆盖整屏的图片,在“lunch”(睡眠2秒,这里要使用异步类,异步停2秒后回到主线程)之后把image的属性设为Gone即可。

       


    作者:老Zhan
    出处:http://www.cnblogs.com/mybkn/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

     
  • 相关阅读:
    JavaScript学习笔记(十六) XMLHttpRequest
    Zabbix 3.0 安装笔记
    jetty端口灵活配置方法
    IDEA15入门常用设置
    [转] 填石头——时间管理
    [转]关于产品的落地
    [转]Netbeans IDE默认UTF-8编码
    如何解决SSH连接Linux超时自动断开?
    ActiveMQ部署步骤和后台管理网站Service Unavailable问题解决笔记
    [转]Maven2中snapshot快照库的使用
  • 原文地址:https://www.cnblogs.com/mybkn/p/2597347.html
Copyright © 2011-2022 走看看