layout 布局 关键在于 android:scaleType=”centerCrop”
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/welcome"
android:scaleType="centerCrop" />
</FrameLayout>
theme,需要在manifest中设置theme
<!
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!
<item name="colorPrimary">@color/color_main_blue</item>
<item name="colorPrimaryDark">@color/color_main_blue</item>
<item name="colorAccent">@color/color_main_orange</item>
</style>
<style name="splash_theme" parent="AppTheme">
<item name="android:windowFullscreen">true</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:background">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/transparent</item>
</style>
<activity
android:name=".activity.SplashActivity"
android:theme="@style/splash_theme"/>
activity
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
mContext = SplashActivity.this;
}
最后上张效果图