Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splash screen activity background color

Tags:

I have problem with my splash screen on Android. Splash screen is displayed to the user during long application startup but activity background is always black. I mean background bitmap (splash image) is visible, but background is black instead of white. I'm using PNG image with transparency.

What I have:

  1. PNG splash screen image with transparent background
  2. Splash screen activity
    [Activity(MainLauncher = true, Theme = "@style/Theme.Splash", NoHistory = true)]     public class SplashScreen : Activity     {         protected override void OnCreate(Bundle bundle)         {             base.OnCreate(bundle);              // Do your app initialization here             // Other long running stuff              // Run app when done             StartActivity(typeof(MainForm));         }     } 
  1. Theme style for splash screen activity in resources/values/styles.xml
    <resources>       <style name="Theme.Splash" parent="@android:style/Theme.Holo.Light">         <item name="android:windowBackground">@drawable/splash_centered</item>         <item name="android:windowNoTitle">true</item>       </style>     </resources> 
  1. Splash drawable in resources/drawable/splash_centered.xml
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"         android:src="@drawable/splash"         android:gravity="center"         android:background="@color/white"> <!-- this is ignored --> 

Problem: As you can see, I'm using Theme.Holo.Light as parent theme and I'm using it in the rest of my app. Holo light is using white background. This white background is not applied on SplashActivity background. SplashActivity background is always black. Background bitmap (splash image) is visible, but background is black instead of white. I'm using PNG image with transparency.

Question: How to set default Holo.Light theme background color (white) on the SplashScreen activity?

Note: I'm using Xamarin.Android, but styling is common for Android platform. Android version 4 and above.

like image 818
Ludwo Avatar asked Oct 02 '14 05:10

Ludwo


People also ask

How do I change the background color of a splash screen?

Use windowSplashScreenIconBackgroundColor to set a background behind the splash screen icon. This is useful if there isn't enough contrast between the window background and the icon.

How do I change the splash screen background color in react-native?

Either use react-native-background-color module from https://github.com/ramilushev/react-native-background-color to set a color on the background which will remove the image. (This is the recommended way because when keyboard shows in some cases, it makes the root view visible for a split second.)

How do you change the background color in splash screen in flutter?

Since we are using our custom color defined in the colors. xml file, we need to change the android:drawable property by inserting the name of our color and deleting the android: part. If we run our project, we'll see our custom background color on the splash screen.

How do I create a splash screen activity?

The most straightforward way to create a simple splash screen was to create a dedicated theme overriding android:windowBackground with a drawable containing branding colors or a bitmap of a logo. The theme was set as an attribute of the launcher activity in AndroidManifest. xml.


1 Answers

In resources/drawable/splash_centered.xml, instead of the bitmap use a layer-list

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">   <item>     <shape android:shape="rectangle">       <solid android:color="@android:color/white" />     </shape>   </item>   <item>     <bitmap android:gravity="center" android:src="@drawable/splash" />   </item> </layer-list> 
like image 102
Jon Canning Avatar answered Oct 20 '22 05:10

Jon Canning