android 启动界面
2016-05-23 16:25
537 查看
在启动一个app时常会有一个启动界面,在ios中直接设置lunch image就行了。不过在android想要实现这种效果就需要代码人为的设置啦。思路也很简单,在启动View只有一张图,让其自己休眠2秒左右的时间,然后跳进mianActivity的主界面就可以了。看代码:
lunch.xml
lunchView.java
其中的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即可。
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即可。
相关文章推荐
- android 使用Bitmap压缩图片
- Android自助餐之adb使用场景
- Android自定义HorizontalScrollView打造超强Gallery效果
- 设计模式在Android源码的运用
- 对话框
- Android 中查看内存的使用情况集常用adb命令
- Android图片下载机制
- Android媒体库更新问题
- Android如何高效显示较大的Bitmaps
- android打包签名介绍
- 你需要知道的Android拍照适配方案
- Android Studio教程 简介与入门(资料比较旧,但有一定参考价值)
- Android统计APK方法数
- RxJava在Android中内存泄漏解决以及RxJava的封装
- Android中HorizontalScrollView使用方法详解
- Android 百分比布局库(percent-support-lib) 解析与扩展
- android 控件 折叠toolbar-CollapsingToolbarLayout
- Android ScrollView和ListView滑动冲突问题
- Android activity的生命周期
- android的ColorStateList简单使用