In my Splash Screen, I have an image that spreads all over the screen and because of this, the image is not looking good - like it got stretched.
I wanted to fix this by adding "android:height" attribute to the Splash Screen style and change the image height but the image remains stretched.
Apparently, the android:height
attribute is affecting all of the views that inside the layout that related to the Splash Screen
This is my style for the splash screen:
<style name="splashScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@mipmap/app_icon</item>
<item name="android:height">100dp</item>
</style>
Any ideas on why android:height
affect the layout views and not the Splash Screen image?
I saw this question talking about different images for different screen sizes, but the difference is that I don't want the image to spread all over the screen.
You using <item name="android:height">100dp</item>
for root view of the Activity. Its not instance of View class, it smth else. And you cant set height for it, Activity should match available area.
To fix stretched image, try this. Set background not a bitmap, but the drawable
<style name="splashScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/shape_background_splash</item>
</style>
and create this drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/white"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/app_icon"/>
</item>
</layer-list>
if you have a bitmap for all scales it should looks good