Android手机ERP开发(二)

来源:互联网 发布:生物多样性计算软件 编辑:程序博客网 时间:2024/04/30 01:08

实现应用开启动画(SplashActivity)  代码格式不好能,发布之后缩进格式什么的都变了,看代码的时候可以拷到eclipse中,代码format之后再看
以下是SplashActivity类,自己工程的包名含有公司名称,就不往外贴了,以下activity需要大家自己导入包。别忘了在注册文件(AndroidManifest.xml)中声明SplashActivity类啊
/**
 * 应用启动页面
 */
public class SplashActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);


// 延迟一定时间进入界面
new Handler().postDelayed(new Runnable() {


@Override
public void run() {

// 登录的场合
if(StatusFlag.isLogin){
ActivityUtils.startActivityLeftIn(SplashActivity.this, SecondaryActivity.class);
}else{
ActivityUtils.startActivityLeftIn(SplashActivity.this, LoginActivity.class);
}
finish();
}
}, 1000);
}
}


以下是R.layout.activity_splash.xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/welcome_imgview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:background="@drawable/welcome" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:text="Copyright?" />

</RelativeLayout>


这个画面就是单纯的显示一张图片和一个版权声明,需要注意一点的是android:background="@drawable/welcome",我们用的是background属性,这就要求welcome图片在放大或缩小的时候,不会影响画质效果。要不然就用android:src="@drawable/welcome"属性配合android:scaleType使用,因为不同的android设备屏幕大小和分辨率不一样,需要做到屏幕适配。有关于Android开发的屏幕适配问题,有兴趣的可以去查查。做到屏幕适配是Android开发中需要注意的。
0 0
原创粉丝点击