Forum Xamarin Xamarin.Android

Xamarin forms splash screen visible navigate to another page

VetriiVetrii Member ✭✭
edited December 2018 in Xamarin.Android

splash screen visible when navigate to new page in xamarin.forms android. i want remove or hide the background image

Answers

  • RylaRyla Member ✭✭

    I did not understand your question.Could you be a little more illustrative?

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please post more details or a basic demo?

  • VetriiVetrii Member ✭✭
    edited December 2018

    <?xml version="1.0" encoding="utf-8"?>

    <!-- Base theme applied no matter what API -->
    <style name="Theme.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>
        <item name="colorAccent">#FF4081</item>
        <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
        <item name="windowActionModeOverlay">true</item>
    </style> <style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar"><item name="android:windowBackground">@drawable/Splash</item> </style>
    

    this is my style.xml . Splashscreen image visible when navigate one page to another page.

  • jezhjezh Member, Xamarin Team Xamurai

    Sorry ,I still can't understand your question. Where is the style.xml file used? Could you please post more details or a basic demo?

  • VetriiVetrii Member ✭✭

    it is in my project.android resource folder

  • PaulNTUPaulNTU USMember ✭✭✭

    It sounds like your splash screen is on the bottom of your view stack and your placing your other views on top of it. When you close a screen it animates the view away thereby showing the splash screen below it in the stack, then your new view loads and animates scrolling in again thereby hiding it again.

    Are you using Xamarin forms? If so the function below will allow you to put your desired view as the only view in your view stack. Its important to note though that if you use this to show your view then the back button will not navigate back to previous views, it will exit your application as there will be no other views to show

            /// <summary>
            /// Show the passed in page as root and unload all others
            /// </summary>
            /// <param name="p">Page to show as root</param>
            public async void ShowAsRoot(ContentPage p)
            {
                // Get list of existing pages
                List<Page> stack = this.Navigation.NavigationStack.ToList();
    
                SetHasNavigationBar(p, false);
                SetHasBackButton(p, false);
    
                // Set new page
                await this.Navigation.PushAsync(p, false);
    
                // Remove all other pages
                foreach (Page n in stack)
                {
                    try
                    {
                        this.Navigation.RemovePage(n);
                    }
                    catch (Exception e)
                    {
    
                    }
                }
            }
    
  • gauravsingh.3387gauravsingh.3387 USMember

    In Activity attribute, let your theme be Theme = "@style/MyTheme.Splash".

    And after LoadApplication(new App());

    You can set your default theme as SetTheme(Resource.Style.Theme.Base);

    It will solve your problem.

  • mivewimivewi DKMember ✭✭

    I've got the same problem. But the "SetTheme" solution is not working for me, I still see the splashscreen inbetween pages. I also see it as a background, when I don't specify any background color on all of my pages.

Sign In or Register to comment.