Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Issue with a splashscreen and a webview

tematimtematim FRMember ✭✭

Hello,

As a sample, I use this project : https://github.com/ozaksuty/Xamarin-Ogreniyorum/tree/master/XamarinTRMenu

In the detail.xaml in PCL, I replace all items by a webview for amazon.com

As I don't want to have a white area before the loading of the page when I launch the app, I want to add a splashscreen for all the app, toolbar included.

I manage to add a view with a logo as Image and media in the resources folder, and a custom activity in the Droid solution with MainLaucher at true and no theme for the MainActivity/ MainLaucher at false, with a style to display a picture.

Next, in my App.cs or App.xaml.cs, I set the MainPage to my SplashScreen and now I need your help to start the navigation and when it's finish, to remove my splashscreen from the view.

I don't find any event to force the navigation, so my application always stay on the splashscreen view and never change.

Could you help me ?

Regards

Answers

  • LucyLu.6013LucyLu.6013 USMember ✭✭✭

    dont put MainPage as splashScreen, put the main page as what u wnat to show after the splash screen disappears...in the app.cs
    create the splashActivity in droid and write the code like this....

    ` [Activity(Theme = "@style/MyTheme.Splash", MainLauncher = false, NoHistory = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class SplashActivity : Activity
    {
    protected override void OnCreate(Bundle bundle)
    {
    base.OnCreate(bundle);

            var intent = new Intent(this, typeof(MainActivity));
            StartActivity(intent);
            Finish();
        }
    }`
    
  • tematimtematim FRMember ✭✭
    edited December 2016

    Hello,

    Thanks for your example. The splashscreen isn't display.

    This is my MainActivity code
    `[Activity(Label = "Vost", Icon = "@drawable/icon", MainLauncher = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : FormsApplicationActivity
    {
    protected override void OnCreate(Bundle bundle)
    {
    base.OnCreate(bundle);

            Forms.Init(this, bundle);
            LoadApplication(new App());
        }
    }`
    

    My SplashScreen code
    ``[Activity(Theme = "@style/Theme.Splash", MainLauncher = false,
    NoHistory = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class SplashActivity : Activity
    {
    protected override void OnCreate(Bundle bundle)
    {
    base.OnCreate(bundle);

            var intent = new Intent(this, typeof(MainActivity));
            StartActivity(intent);
            Finish();
        }
    }
    

    My styles.xml code
    ?xml version="1.0" encoding="utf-8" ?
    resources
    style name="Theme.Splash" parent="android:Theme"
    item name="android:windowBackground">@drawable/logo</item
    //This disables the black preview screen
    item name="android:windowDisablePreview">true</item
    item name="android:windowNoTitle">true</item
    /style
    /resources

    Thanks in advance

  • tematimtematim FRMember ✭✭

    A little message about my issue that still here

  • zeshanarifzeshanarif Member

    use MainLauncher = false in your MainActivity and MainLauncher = true in your SplashActivity

Sign In or Register to comment.