我试图添加一个启动画面到Xamarin.Forms中的我的Android应用程序,但我得到一个奇怪的例外,即时通讯尝试解决没有成功。继承人异常的屏幕。我不知道为什么我需要使用“Theme.AppCombat”?对我来说很奇怪,我无法自己解决这个问题。Java.Lang.RuntimeException无法启动活动
我的资源/价值/ style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Splash" parent="android:Theme">
<item name="android:windowBackground">@drawable/splash</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
MainActivity.cs
[Activity(Label = "Ummah",
Icon = "@drawable/Icon",
MainLauncher = false,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity {
protected override void OnCreate(Bundle bundle) {
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
和我SplashActivity.cs
[Activity(Theme = "@style/Theme.Splash",
MainLauncher = true,
NoHistory = true)]
public class SplashActivity : AppCompatActivity {
protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
StartActivity(typeof(MainActivity));
}
}
有你试图定义你Theme.Splash为'<样式名称= “Theme.Splash” 父= “Theme.AppCompat”>'? – antonio
公共类SplashActivity:活动解决了我的问题。 –