目前應用程式在啟動的時候都會有一個展示自己公司LOGO和APP名字的界面。這個界面成為SplashActivity。
xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<TextView android:id="@+id/copy_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dip"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:text="by xxxxx 出品"
android:textSize="11sp"/>
<RelativeLayout
android:layout_height="fill_parent">
<LinearLayout
android:layout_centerInParent="true">
android:layout_gravity="center_horizontal">
<ImageView android:id="@+id/jay_studio_icon"
android:layout_width="110dip"
android:layout_height="130dip"
android:src="@drawable/ic_launcher"/>
<ImageView
android:layout_toRightOf="@id/jay_studio_icon"
</RelativeLayout>
<LinearLayout android:layout_width="wrap_content"
<TextView
android:id="@+id/app_name"
android:padding="6dip"
android:text="appname"
android:textSize="24sp"/>
android:id="@+id/version_name"
android:gravity="bottom"
android:paddingBottom="6dip"
android:textSize="14sp"/>
</LinearLayout>
<View android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:background="#dddddd"/>
<TextView android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:text="傳承曆史"
android:textSize="13sp"/>
<ProgressBar android:id="@+id/refresh_list_footer_progressbar"
android:layout_width="24dip"
android:layout_height="24dip"
android:layout_gravity="center">
</ProgressBar>
譬如檢查網絡。載入本地資料庫等等。。
。
可是在運作完。須要跳轉到第二個界面,比較好的互動效果,是給Activity的切換時加入動畫。
流程:
SplashActivity展示1秒後,跳轉到下一個界面(主屏),跳轉過程使用動畫。
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="2000" />
</set>
因為Application的生命周期比Activity長,利用這個特點。把一些載入資料庫。複制資料庫檔案,讀取資料庫。而網絡資料能夠放在異步任務裡來完畢。
效果:
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiIXZ05WZD9CX5RXa2Fmcn9CXwczLcVmds92czlGZvwVP9EUTDZ0aRJkSwk0LcxGbpZ2LcBDM08CXlpXazRnbvZ2LcRlMMVDT2EWNvwFdu9mZvwVMFRUT510MjxGetlldRhlW1VTaitmTzkVdjJjYzpkMMZ3bENGMShUYvwFd4VGdvwlMvw1ayFWbyVGdhd3PyIjMxEzMxEjMwEjNwUTMwIzLcRXZu5ibkN3Yuc2bsJmLn1Wavw1LcpDc0RHaiojIsJye.jpg)
本文轉自mfrbuaa部落格園部落格,原文連結:http://www.cnblogs.com/mfrbuaa/p/5097820.html,如需轉載請自行聯系原作者