SplashScreen Andorid by xamarin form error

brux88brux88 USMember ✭✭

Good evening everyone, I'm trying to create the splash screen for Android by Xamarin form, was suggested to me to follow this https://developer.xamarin.com/guides/android/user_interface/creating_a_splash_screen/ guide, I also tried other guides, but the error is always the same:
No resource found That matches the given name (at 'theme' value with '@ styles / MyTheme.Splash').
I'm filling in for Android 6, and my activity inherit from FormsApplicationActivity do not know if it can be useful ...
I can not find the topic as I understand it, although I have followed step by step the official guide

Answers

  • DiomedesDominguezDiomedesDominguez DOMember ✭✭

    Remember that you must create an XML file name Styles in the values folder. 'MyTheme.Splash' is the name of the style.

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
      <style name="Theme.Splash"
        parent="android:Theme">
        <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>
    </resources>
    
  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
  • brux88brux88 USMember ✭✭
    edited July 2016

    Yes, i have create XML file intorno style , andiamo in try the example Corrado but the same error

  • DiomedesDominguezDiomedesDominguez DOMember ✭✭

    (Look the attachment)

    SplashScreen.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
      android:src="@drawable/splash"
      android:gravity="center"
      android:layout_gravity="center"/>
    

    Styles.xml

    <?xml version="1.0" encoding="utf-8" ?> 
    <resources>
      <style name="Theme.Splash"
        parent="android:Theme">
        <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>
    </resources>
    

    SplashScreen.cs

        [Activity(Label = "GoToMarket", MainLauncher = true, NoHistory = true, Theme = "@style/Theme.Splash",
            ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
        public class SplashScreen : Activity
        {
            #region Protected Methods
    
            protected override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);
    
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            }
    
            #endregion Protected Methods
        }
    

    MainActivity.cs

        [Activity(Label = "GoToMarket", Icon = "@drawable/icon", Theme = "@android:style/Theme.Holo.Light",
            ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
        public class MainActivity : FormsApplicationActivity
        {
            ...
    
  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Shouldn't:

    @styles/MyTheme.Splash'
    

    be:

    @style/MyTheme.Splash
    

    ?

    Also, make sure you set the build action on your xml file to AndroidResource.

  • brux88brux88 USMember ✭✭

    Thanks, now I try and let you know

  • BeXamarinBeXamarin INMember

    Hi Brux88,

    So have you tried? what was the result?

  • brux88brux88 USMember ✭✭

    yes now work

Sign In or Register to comment.