Xamarin图标透明度混乱

时间:2017-12-23 22:46:31

标签: android xamarin icons

非常简单:如何确保图标背景透明度生效?

我在透明背景上有文字或图像的图标和启动画面。当安装在Android设备上时(多个/每个设备),我得到一个白色正方形图标,而不是按预期显示,并且启动屏幕往往显示黑色背景。

这就是我希望我的图标看起来像什么(适用于浏览器,常见的图片浏览器,Playstore等):

enter image description here

基本上,我得到了这个:

enter image description here

抱歉这个蹩脚的例子。我手绘油漆。我的MainActivity看起来像这样......

[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
    {...

我的styles.xml如下所示:

 <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 个答案:

答案 0 :(得分:0)

这是我们如何在PhotoShop中保存png文件以及Visual Studio如何查看alpha通道的存在(或缺少)的问题。虽然他们确实在后台设置了透明度,但我们必须将它们显式设置为32位图像,否则Visual Studio会忽略/假设没有alpha通道。

最后,只需在Visual Studio Asset Editor中打开图像并注意:

即可确定问题

请注意,它必须如下所示:“32位”

enter image description here

相关问题