一、启动页的实现步骤:
1、Activity实现
public class MainSplashActivityextends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_splash)
startActivity(new Intent(MainSplashActivity.this, MainActivity.class));
finish();
}
}
2、styles.xml文件中增加theme定义
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/bg_splash</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
3、增加启动图bg_splash.xml
其中splash为真正的图片
<?xml version="1.0" encoding="utf-8"?>
<layer-list>
<item>
<shape>
<solid android:color="@color/white"/>
</shape>
</item>
<item android:bottom="10dp">
<bitmap
android:gravity="bottom"
android:src="@mipmap/splash"/>
</item>
</layer-list>
4、在Manifest文件中,对activity指定theme
<activity android:name=".MainSplashActivity" android:theme="@style/SplashTheme">