設(shè)置完App圖標(biāo)接下來設(shè)置App的歡迎界面
在你創(chuàng)建完SplashActivity后在res/layout目錄下會自動生成一個activity_splash.xml酪我,這個就是歡迎界面對應(yīng)的布局文件
首先將歡迎界面的圖片文件復(fù)制粘貼到res/drawable目錄下剥悟,再寫布局文件
activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/launch_bg">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/pb_splash_loading"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:id="@+id/tv_splash_version"
android:text="version:1.0"
android:layout_below="@+id/pb_splash_loading"/>
</RelativeLayout>
ProgressBar
ProgressBar有幾種類型昭伸,此處我們使用最普通的類型俊戳,樣式就是一個一直在轉(zhuǎn)的進(jìn)度圈
match_parent和wrap_content是比較常用的兩個布局屬性,match_parent可以理解為填滿剩余空間的意思浩嫌,而wrap_content可以理解為大小取決于內(nèi)容
然后進(jìn)行垂直居中和水平居中就把ProgressBar放到了一個比較合適的位置
TextView
TextView就是放一段文字超歌,layout_below的意思是將當(dāng)前控件放在指定id控件的下面,在此處就是將App的版本號放在進(jìn)度圈下方
此時運(yùn)行出來的效果如下