我正在尝试为我的应用创建启动画面。 我正在使用xamarin表单,目前仅在Andorid中进行测试
但是我收到这2个错误
1)无法为拆分''“生成资源表。”未能为拆分''“生成资源表。
2)严重程度为Cod'android:windowBackground',值为'@ drawble / splashscreen'。
将寻求任何帮助来解决此问题
谢谢。
这是我的styles.xml:
<resources>
<style name="Theme.splash" parent="android:Theme">
<item name="android:windowBackground">@drawble/splashscreen</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without
android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from
http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
这是我添加到“活动”中的代码:
[Activity(Label = "SplashScreen", MainLauncher=true, NoHistory=true, Theme = "@style/Theme.splash")]
public class SplashScreen : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
StartActivity(typeof(MainActivity));
}
}
这是主要的积极性:
[Activity(Label = "RegestrationAppComp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
答案 0 :(得分:1)
请使用Visual Studio在可绘制文件夹中添加图像(在本例中,图像文件名为“ splashscreen”)。为此,您必须右键单击“ Drawable”文件夹->单击“添加现有项”->从便携式计算机/ PC驱动器位置选择图像,然后单击“添加”。就是这样!现在,您可以再次构建和部署解决方案。.
答案 1 :(得分:0)
在创建splashscreen.xml文件时,必须更改其属性。我已按照以下步骤操作:
Build Action
上,将值更改为AndroidResource
Custom Tool
上写MSBuild:UpdateGeneratedFiles
(或复制上面同一文件夹中的其他文件上的内容或从values/styles.xml
文件中写的内容。