I am making a splash screen by changing the
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
property of a theme.
This drawable/background_splash looks like this
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:drawable="@color/colorPrimary"/>
<item>
<bitmap
android:src="@drawable/ic_logo_black"
android:gravity="center"/>
</item>
</layer-list>
For my launcher activity, it does some calculation in the back, and then conditionally navigate to other activities. This calculation requires server so it will stay on this activity for some time.
In order to make the experience better, I would like this activity to look the same as the splash screen.
So I basically did this for the layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_splash"
android:orientation="vertical">
</RelativeLayout>
However, with this setup. I can notice that the logo is shifted upwards by about 5-10 px once it goes from splash screen to the launcher activity.
My question is, what can I do so that this shift is completely gone? I can obviously hardcode some margins around. But i am not sure if that will for all devices sizes.
What is that 5-10px shift anyway? i basically used the exact image as the background in the layout.
I notice that if I don't set any background for my splashActivity layout, this issue is resolved. But I would still like a background because during my user work flow, user might be redirected to this screen. I don't want them to see an empty blank screen =/
Thank you for your nice question
I found a way, change 'drawable/background_splash' to
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item>
<color android:color="@color/colorPrimary" />
</item>
<item android:bottom="48dp">
<bitmap
android:src="@drawable/ic_logo_black"
android:layout_width="wrap_content"
android:tileMode="disabled"
android:layout_height="wrap_content"
android:scaleType="fitCenter"/>
</item>
</layer-list>
Seems bar height(48dp) in splash layout is not bound !
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