I've assigned a drawable resource to my app's loading theme. However, the bitmap within the drawable resource is being clipped and I can't figure out why. Using android:gravity="fill_horizontal" stops the horizontal clipping, but also changes the image's aspect ratio.
How can I use the image without clipping the edges and while maintaining its original aspect ratio?
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- Launcher/splash theme. -->
<style name="AppTheme.Launcher">
<item name="android:windowBackground">@drawable/launch_screen</item>
<item name="android:adjustViewBounds">true</item>
</style>
</resources>
launch_screen.xml
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- Background color-->
<item android:drawable="@android:color/white"/>
<!-- Splash Logo -->
<item>
<bitmap
android:src="@drawable/splash_screen"
android:gravity="center"/>
</item>
</layer-list>
Bitmap using---android:gravity="center"
Bitmap using---android:gravity="fill_horizontal"
Temporary Solution: I've found an imperfect solution. By tweaking the item's height and width I've managed ensure the image remains within the container's boundaries. The image does not scale equally across different screen sizes. For now, this setting is the best solution I've come across.
Amended launch_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Use android:opacity=”opaque” to prevent black flash during theme
transition. -->
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- Background color-->
<item android:drawable="@android:color/white"/>
<!-- Splash Logo -->
<item
android:height="400dp"
android:width="400dp"
android:gravity="center">
<bitmap
android:src="@drawable/splash_screen"
/>
</item>
</layer-list>