I have been reading much about Xamarin for sometime and how to make a splash screen. I am quite new to something like this and hence i wanted to ask on here, Why is the splash screen not redirecting to the login page in the Emulator'
i am using Visual Studio 2019, I added a new folder drawable-hdpi and then added the images to it to be used inside the xaml. Now what? it does not redirect!
Here is what my code looks like
Splash screen Xaml (MainPage.xaml)
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="VisitorMan.MainPage"
BackgroundColor="#fff">
<StackLayout HorizontalOptions="Center" VerticalOptions="Center" Padding="10">
<Image Source="splash_logo.png" x:Name="imgLogo" HeightRequest="150" WidthRequest="150"/>
</StackLayout>
</ContentPage>
The corresponsing MainPage.xaml.cs File Looks like this
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace VisitorMan
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
Animate();
}
public async Task Animate()
{
imgLogo.Opacity = 0;
await imgLogo.FadeTo(1, 4000);
Application.Current.MainPage = new LoginPage();
}
}
}
The Login Page which shows the username and password (LoginPage.xaml) Looks like this
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="VisitorMan.LoginPage"
BackgroundColor="#fff">
<ContentPage.Content>
<StackLayout Spacing="20" Padding="50" VerticalOptions="Center">
<Image Source="splash_logo.png" x:Name="imgLogo" HeightRequest="150" WidthRequest="150"/>
<Entry Placeholder="Username"></Entry>
<Entry Placeholder="Password" IsPassword="True"></Entry>
<Button Text="Log In" TextColor="White" BackgroundColor="#ff77D065"></Button>
</StackLayout>
</ContentPage.Content>
</ContentPage>
The splashscreen is just standstill and does not redirect to the Login Page. Could there be something i am missing?
Resources
folder in Android . Make sure the name of image is correct used in Forms and be reaally add to project. – Junior Jiang