I'm a beginner in mobile app development and I'm developing an android app using Xamarin forms for a project.
On my Xamarin forms project, I have to add a splash screen at startup. to accomplish this I have to put this code on my MainPage.XAML
<Grid>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Grid x:Name="SplashGrid" BackgroundColor="{StaticResource Primary}">
<Image x:Name="Logo" Source="Logo" HorizontalOptions="Center" VerticalOptions="Center">
<Image.TranslationY>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="Android">-12</On>
</OnPlatform>
</Image.TranslationY>
</Image>
</Grid>
</Grid>
But my main page is a Tabbed page and not a content page.
What can I do to achieve a splash screen while my main page remains tabbed?
if my tabbed page can be opened automatically after loading the main page, that would be fine too.
this is how the constructor of my App.xaml.cs looks.
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new TabbedPageContainer());
}
I really appreciate your help. Thanks in advance.
public class App : Application
{
public App()
{
InitializeComponent();
}
protected override async void OnStart()
{
// show the splash
MainPage = new SplashPage();
// simple wait or initialize some services
await Task.Delay(2000);
// show the real page
MainPage = new NavigationPage(new TabbedPageContainer());
}
}
Normally, we use drawable resource to create the splash screen. Follow the stpes below.
You could follow the stpes on the link below. It works well on tabbed page. Xamarin forms custom splash screen
For more about IOS, you could check the link.
https://medium.com/@thesultanster/xamarin-splash-screens-the-right-way-3d206120726d https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/splashscreen
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.