In my SlashActivity
I use only AndroidManifest
and style
as advised here https://www.bignerdranch.com/blog/splash-screens-the-right-way/.
And in SplashActivity
I want use splash.jpg
, but this picture changing to screen size.
How I can use centerCrop
in my style
file or are there other solutions?
My drawble:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/colorMaterialWhite"/>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash" />
</item>
</layer-list>
AndroidManifest:
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
SplashActivity:
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, NavigationActivity.class);
startActivity(intent);
finish();
}
}
Style:
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
You might want to add padding to your splash image.
Inside the item tag add android:top
, android:bottom
, android:right
, android:left
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/colorMaterialWhite"/>
<item
android:top="200dp"
android:bottom="200dp"
android:left="200dp"
android:right="200dp">
<bitmap
android:gravity="center"
android:src="@drawable/splash" />
</item>
</layer-list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With