In my application, I'm trying to set the splash t
heme with a drawable background
. It works correctly if I use a small image, but when the image is bigger then the screen size, it doesn't work anymore.
The image is correctly scaled horizzontally, but the height
isn't, as follows:
I tried every scaletype and gravity, what else can I do?
this is my Theme:
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
This is my background_splash.xml
<item android:drawable="@android:color/white" />
<item
android:left="50dp"
android:right="50dp"
>
<bitmap android:src="@drawable/logo_splash"
android:gravity="center|clip_horizontal"
android:scaleType="centerInside"
/>
</item>
and this is my manifest (relevant code):
<activity
android:name=".activities.SplashScreenActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any idea?
You can use a layer-list like this in your background_splash.xml:
This will center your image on the screen and the left space will be filled by the white background color.
Maybe you have to add the image in different sizes like you can read here: https://developer.android.com/training/multiscreen/screendensities#TaskProvideAltBmp
If you do that you can access the image with the same name. It will look like this your project structure:
If you want to remove the action and status bar in your splash screen, you can add the following line to your SplashTheme: