我的Android应用程序启动时有一个闪屏问题。虽然背景位图(闪屏图片)可见,但背景总是黑色的,而不是白色的。我使用带有透明度的PNG图像。
我拥有的内容:
- 带有透明背景的PNG闪屏图片
- 闪屏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));
}
}
- 在资源/值/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>
- 在资源目录下的drawable文件夹中,有一个名为splash_centered.xml的Splash drawable。
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splash"
android:gravity="center"
android:background="@color/white"> <!-- this is ignored -->
问题: 如您所见,我正在使用Theme.Holo.Light作为父主题,并在我的应用程序的其余部分中使用它。 Holo light使用白色背景。 但是,SplashActivity背景上没有应用此白色背景。 SplashActivity的背景始终是黑色的。 背景位图(启动画面图像)可见,但背景是黑色而不是白色。 我正在使用带有透明度的PNG图像。
问题: 如何在SplashScreen活动中设置默认的Holo.Light主题背景颜色(白色)?
注意: 我正在使用Xamarin.Android,但样式适用于Android平台。 Android版本4及以上。