Xamarin.android 向splashscreen添加布局
是否可以向MvxSplashScreenActivity添加布局?我已经像在所有其他活动中一样覆盖了OnViewModelSet,并放置了以下代码:Xamarin.android 向splashscreen添加布局,xamarin.android,splash-screen,mvvmcross,Xamarin.android,Splash Screen,Mvvmcross,是否可以向MvxSplashScreenActivity添加布局?我已经像在所有其他活动中一样覆盖了OnViewModelSet,并放置了以下代码: protected override void OnViewModelSet() { base.OnViewModelSet (); SetContentView (Resource.Layout.SplashScreen); } 我尝试加载的布局是: <RelativeLayout xmln
protected override void OnViewModelSet()
{
base.OnViewModelSet ();
SetContentView (Resource.Layout.SplashScreen);
}
我尝试加载的布局是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ImageView
android:src="@drawable/applogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:layout_centerInParent="true" /></RelativeLayout>
我得到以下例外情况:
Cirries.CrossCore.Exceptions.MvxException:未能解析类型
Cirries.MvvmCross.Binding.BindingContext.IMvxBindingContextStack`1[[Cirries.MvvmCross.Binding.Droid.BindingContext.IMvxAndroidBindingContext,
Cirrius.MvvmCross.Binding.Droid,版本=1.0.0.0,区域性=中性,
PublicKeyToken=null]]
我似乎在网上找不到关于mvvmcross启动屏幕的任何信息
好主意吗?您不能在splashscreen中使用数据绑定布局-splashscreen在mvvmcross完全启动之前显示 但是,对于一个简单的布局,您可以将资源Id向下传递给基类构造函数:
public class SplashScreen : MvxSplashScreenActivity
{
public SplashScreen()
: base(Resource.Layout.SplashScreen)
{
}
}
进一步-为了避免黑启动屏幕-大多数人使用一个主题来指定其splashscreen中的整个屏幕图像-请参阅nuget提供的“标准”splashscreen-在调用OnCreate之前确保初始化设置
protected override void OnCreate(Bundle bundle)
{
var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this);
setupSingleton.EnsureInitialized();
base.OnCreate(bundle);
}
对于Android来说,嵌入飞溅图像并不是理想的方法,因为屏幕的比例不同,所以位图图像会失真。应改用SplashScreen.axml。