Forum Xamarin.Android

Android Splash screen question

I need to display a splash screen on my Android app, but I need to have its proportions unchanged.

The tutorial shown on the Xamarin web site ( is using a style with a background image:

  <style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowNoTitle">true</item>

Unfortunatly, the image proportions are modified so it looks distorted on some screen resolutions.
It looks like the image is displayed with the FitXY parameter.
I would like the image to be scaled (liek fill_parent), but with its proportions unchanged (!fitXY)

How to achieve this?

Note : I tried to use different styles according to the device density (lp, hp, etc.) but it is not enough since this way I cannot handle all screen ratios.


  • CheesebaronCheesebaron DKInsider, University mod

    Background images in themes will always stretch to fit the view. Unless... You use this little hack:


    <?xml version="1.0" encoding="utf-8"?>
    <bitmap xmlns:android=""
        android:tileMode="disabled" android:gravity="top" >



      <style name="Theme.Splash" parent="android:Theme">
        <item name="android:windowBackground">@drawable/splashimage</item>
        <item name="android:windowNoTitle">true</item>

    This is grabbed from the following SO answer:

  • KurtLangerKurtLanger USMember


    Thank you for your answer, but this is not what I need exactly.
    With your code, the image is not distorted (which is cool), but is displayed at size 1:1, i.e. not scale to fit the screen.
    What I need is simple, this is the default behavior of an image put in a layout, like this:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android=""
            android:id="@+id/imageView1" />

    As you can see, this image is displayed with its proportion kept, but streteched to fit the screen. If the image ratio is not the same as the screen ratio, the black bands witll be dispalyed either at top/bottom of the screen, or at top/bottom of the screen.
    This is what I need, but in the splash screen.

  • CheesebaronCheesebaron DKInsider, University mod

    You can try play with the Gravity attribute. The different types you can use can be found here:

    Something like fill or fill_horiziontal might be what you are looking for.

  • How do create a splash screen that fade out when the activity fades in?

  • CheesebaronCheesebaron DKInsider, University mod
    edited February 2014

    @HashtagAndroid‌ you will need to look into how OverridePendingTransition works.

    Some more info in this StackOverflow question.

Sign In or Register to comment.