I am trying to create an Android splash screen that has two images: one in the center of the screen and one that is about 20% away from the bottom of the screen. Is there any way to do this?
The approach I tried thus far is to have a SplashActivity as the first activity and the manifest file sets the theme as SplashTheme:
In AndroidManifest.xml:
<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Then in styles.xml I define this theme:
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
Next I create the drawable file background_splash.xml and this is where I have questions:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/dark_gray" />
<padding
android:left="0dip"
android:top="0dip"
android:right="0dip"
android:bottom="0dip" />
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/mainlogo"/>
</item>
<item android:bottom="@dimen/splash_bottom">
<bitmap android:src="@mipmap/bottom_logo"
android:gravity="bottom" />
</item>
</layer-list>
This actually sort-of works, the mainlogo is indeed in the center and the bottom_logo is some distance above the bottom. The problem is that I need to specify values in dp for splash_bottom in dimens.xml. Doing this accurately for ldpi, mdpi, hdpi xhdpi etc is really hard to get right.
Isn't there a way inside the drawable file background_splash.xml to place the bottom_logo 20% from the bottom of the screen?
The desired splash screen looks something like this (not the actual screen - I borrowed this from another SO post - see Android: how to align 2 images on a splash screen):