Incorrect splash screen size

I use the style below to show the splash screen in the Xamarin app for Android, however the image is always displayed with the wrong size. I would like it to resize with the correct dimensions, but 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> 

Screen Saver 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)); } } 
+8
android xamarin splash-screen
source share
3 answers

One of the problems is that windowBackground is sized to full screen, including a status bar at the top or bottom of the device. But the status bar is still displayed. My answer to the Android Activity Background Image uses windowContentOverlay, which excludes the status bar.

+3
source share

Take a look at:

Android: scale graphic or background image?

Basically, this allows you to specify how to clip or stretch the image when the image is smaller than the border of the screen. I think the author of this answer gives a good explanation, and that may be what you are looking for.

-one
source share

When I had problems displaying images in my application, I found this useful site: Android scale types

Here are the results of the various types of scales you can use. Hope this helps!

-2
source share

All Articles