I use a png bitmap file in my splash screen. In addition, I have tried to display exactly the same image with ImageView but then the bitmap looks much smaller on my Android tablet.
The image resolution is 288x288 px and I use the same image resolution in the drawable folders because I'm not sure which resolutions I should use for each folder. I have added the image splash_logo to the following drawable folders:
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
The file ic_splash_screen_image.xml is located in the folder Drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/splash_background"/>
</item>
<item>
<bitmap
android:src="@drawable/splash_logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
The files colors.xml and styles.xml are located in the folder Values:
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<color name="splash_background">#000000</color>
<color name="custom_color">#4cb3fc</color>
</resources>
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:colorPrimary">#2196F3</item>
<item name="android:colorPrimaryDark">#1976D2</item>
<item name="android:colorAccent">#FF4081</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="SplashTheme" parent ="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@android:color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash_screen_image</item>
<item name="postSplashScreenTheme">@style/MainTheme</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
In Activity1.cs, I ise the following code to draw the image:
[Activity(
Label = "@string/app_name",
MainLauncher = true,
Icon = "@mipmap/icon",
Theme = "@style/SplashTheme",
AlwaysRetainTaskState = true,
LaunchMode = LaunchMode.SingleInstance,
ScreenOrientation = ScreenOrientation.UserLandscape, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize
)]
public class Activity1 : AndroidGameActivity, ViewTreeObserver.IOnGlobalFocusChangeListener
{
FrameLayout layout;
View splashView;
protected override void OnCreate(Bundle bundle)
{
AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen(this);
base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(bundle);
layout = new FrameLayout(this.ApplicationContext);
layout.AddView((View)_game.Services.GetService(typeof(View)));
splashView = new ImageView(this.ApplicationContext);
((ImageView)splashView).SetBackgroundResource(Resource.Drawable.ic_splash_screen_image);
layout.AddView(splashView);
SetContentView(layout);
}
}
Why does the bitmap look much smaller when I use ImageView instead of the splash screen to draw the bitmap?