Android - 初学者- SlashActivity - 过场动画

因为一进入页面,可能会需要过场画面,显示个logo或显示个资料确认中之类的

通常可能称这个画面为SlashActivity或LauncherActivity

最简单的是摆一个属于自己的logo或loading

大概画面如下这样

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="5dp"
    android:gravity="center_horizontal|center_vertical"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/iv_logo"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_centerInParent="true"
        android:src="@drawable/logo"
        android:visibility="visible" />
</LinearLayout>

但因为过场太快,可能连图片都看不到,就可能到了下一页,

所以希望能停顿个一秒或500毫秒

就还要加上Handler处理

    @Override
    protected void onResume() {
        super.onResume();

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                //to your MainActivity
            }

        }, 1000);
    }

大概就这样完成了一个过场画面。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章