Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splash screen is resizing incorrectly

I am using the style below to show a splash screen in my Xamarin Android application however the image always shows with incorrect sizing. I would like it to resize with the correct dimensions however it always expands to fit the screen.

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/splashscreenimage</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:adjustViewBounds">true</item>
    <item name="android:scaleType">centerCrop</item>
  </style>
</resources>

The splash screen activity

  [Activity(MainLauncher = true, Theme = "@style/Theme.Splash", NoHistory = true)]
  public class SplashScreenActivity : Activity
  {
    protected override void OnCreate(Bundle bundle)
    {
      base.OnCreate(bundle);

      // Start our real activity
      StartActivity(typeof(LoginActivity));
    }
  }
like image 803
Telavian Avatar asked May 11 '13 19:05

Telavian


People also ask

What size should a splash screen image be?

Splash Screen dimensions The splash screen icon uses the same specifications as Adaptive icons, as follows: Branded image: This should be 200×80 dp. App icon with an icon background: This should be 240×240 dp, and fit within a circle of 160 dp in diameter.


1 Answers

For background drawable you should use layer-list. For example make bitmap_splash.xml:

<item android:drawable="@color/background"/>

<item>
    <bitmap
        android:gravity="center"
        android:src="@drawable/splashscreenimage" />
</item>

and then use it in your style:

...
<style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/bitmap_splash</item>
...
like image 194
ivan.panasiuk Avatar answered Sep 18 '22 12:09

ivan.panasiuk