I am using a theme on my application so that when it start's up, the first thing a user sees is my background instead of an ugly black or white screen with an action bar on top.
<style name="LoadingTheme" parent="android:Theme.Holo.Light.NoActionBar">
<item name="android:windowBackground">@drawable/loading_home</item>
</style>
Simple enough. The problem is that, this screen transitions into my Splash page/Loading activity, which is displaying the same background image but with some scaling:
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:src="@drawable/loading_home"/>
My issue is, that in my Splash page (the image view above), the background is displaying as I would like it, in that it does not look stretched (I believe due to fitCenter). However, in my application style, the background becomes stretched. Is there a way that I can apply scaleType to a background in a theme, or another method in which I can have control over the scaling of the background image in my application theme?
Try to wrap your png in a xml file, and use the xml as windowBackground in the style, like so
window_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:src="@drawable/loading_home" />
styles.xml
<item name="android:windowBackground">@drawable/window_bg</item>
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