I am trying to re-create a splash screen to conform to Google standard. I tried creating a background drawable for my splash screen which I'll be setting in theme itself. But I am looking for a way to make the bitmap match the parent.
Below is my drawable code: splash_screen_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:gravity="center">
<bitmap android:src="@drawable/logo_show" android:gravity="center" />
</item>
</layer-list>
Here is code where I am setting this drawable as background of an activity:
<style name="SpTheme" parent="SearchActivityTheme.NoActionBar">
<item name="colorPrimaryDark">@color/colorAccentXDark</item>
<item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
<item name="android:windowBackground">@drawable/splash_screen_bg</item>
</style>
You can't scale image in bitmap. It isn't ImageView
so it hasn't scaleType
attribute. Your image will scale depending on folder you put it (drawable-xdpi,drawable-nodpi,...). You just can set backround fill color to what you need.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/colorPrimary"/>
<item android:gravity="center">
<bitmap android:src="@drawable/logo_show" android:gravity="center" />
</item>
</layer-list>