1
votes

Quite simply: How does one ensure the icon background transparency takes effect?

I have Icons and Splash Screens with text or images over a transparent background. Instead of displaying as expected, I get a white square for the icons when installed on the Android device (multiple/every device) and the splash screens tend to appear with a black background.

Here's what I want my icon to look like (works in browsers, common pic viewers, playstore etc):

enter image description here

Basically, I get this instead:

enter image description here

Sorry for the lame example. I made this by hand in paint. My MainActivity looks like this...

[Activity(LaunchMode = LaunchMode.SingleTop, MainLauncher = true, Label = "myapp", Icon = "@drawable/icon", Theme = "@style/splashscreen", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {...

My styles.xml looks like this:

 <style name="splashscreen" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/splashscreen</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">true</item>
  </style>
1
@SushiHangover No? If I'm supposed to use that for a splashscreen or icon, that's not mentioned in any guides. Such as: developer.xamarin.com/guides/android/user_interface/… or here: developer.xamarin.com/guides/android/advanced_topics/…maplemale
@SushiHangover FYI: My picture might be confusing... I cannot share a real screenshot of the Android Apps list or home screens etc. due to intellectual property rights (cannot display actual icon in question).maplemale
That should work fine, what is the format of your splashscreen drawable?SushiHangover
@SushiHangover It is a 320x480 png (other sizes depending on the drawable folder / device size). It has the logo at the top, some text underneath (all mostly black colors) and transparent background. The splash screen just shows black on bootup and anything that's black (most of my splash screen / logo is black) ends up being invisible. I've tried setting the background as white in the styles.xml. But, that just ends up white-ing out the splash screen and I see nothing but white instead of black on white. It's acting like Xamarin just doesn't support backgrounds with transparent splash.maplemale
@SushiHangover Honestly... I probably shouldn't have mentioned the splash screen because thinking about it, I can just make that non-transparent, give it a background and all should be well. Though it's annoying that xamarin seemingly doesn't support transparent splash. I'm more concerned as to why the icons for the tool bar, app list etc. aren't rendering as expected - with a white square/box around them instead of transparent.maplemale

1 Answers

0
votes

This was an issue with how we were saving the png files in PhotoShop and how Visual Studio views the existence (or lack of) an alpha channel. While they did have transparency set in the background, we had to explicitly set them to 32 bit images otherwise Visual Studio would ignore / assume there was no alpha channel.

Eventually the issue was identified by simply opening the images in Visual Studio Asset Editor and noting:

Note here, it must look like this: "32 bit"

enter image description here