繁体   English   中英

带有选项卡式主页 Xamarin 表单的启动画面

[英]Splash screen with Tabbed main page Xamarin forms

我是移动应用程序开发的初学者,我正在使用 Xamarin 表单为项目开发 android 应用程序。

在我的 Xamarin 表单项目中,我必须在启动时添加启动画面。 为此,我必须将此代码放在 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>

但我的主页是标签页而不是内容页。

当我的主页保持选项卡时,我可以做些什么来实现启动画面?

如果我的标签页可以在加载主页面后自动打开,那也可以。

这就是我的 App.xaml.cs 的构造函数的外观。

public App()
        {
            InitializeComponent();
            MainPage = new NavigationPage(new TabbedPageContainer()); 
        }

我真的很感谢你的帮助。 提前致谢。

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()); 
    }
}

通常,我们使用可绘制资源来创建启动画面。 按照以下步骤操作。

您可以按照以下链接中的步骤操作。 它在选项卡式页面上运行良好。 Xamarin 表单自定义启动画面

在此处输入图片说明

有关 IOS 的更多信息,您可以查看链接。

https://medium.com/@thesultanster/xamarin-splash-screens-the-right-way-3d206120726d https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/splashscreen

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM