带有选项卡式主页 Xamarin 表单的启动画面 [英] Splash screen with Tabbed main page Xamarin forms

查看:40
本文介绍了带有选项卡式主页 Xamarin 表单的启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是移动应用开发的初学者,我正在使用 Xamarin 表单为项目开发 Android 应用.

在我的 Xamarin 表单项目中,我必须在启动时添加启动画面.为此,我必须将此代码放在 MainPage.XAML

<!-- 在此处放置新控件--><Label Text="欢迎使用 Xamarin.Forms!"水平选项=中心"VerticalOptions="CenterAndExpand"/><Grid x:Name="SplashGrid" BackgroundColor="{StaticResource Primary}"><Image x:Name="Logo" Source="Logo" Horizo​​ntalOptions="Center" VerticalOptions="Center"><Image.TranslationY><OnPlatform x:TypeArguments="x:Double"><On Platform="Android">-12</On></OnPlatform></Image.TranslationY></图片></网格></网格>

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

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

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

这是我的 App.xaml.cs 的构造函数的样子.

公共应用程序(){初始化组件();MainPage = new NavigationPage(new TabbedPageContainer());}

非常感谢您的帮助.提前致谢.

解决方案

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

您可以按照以下链接中的步骤操作.它在选项卡式页面上运行良好.

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

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

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.

解决方案

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

这篇关于带有选项卡式主页 Xamarin 表单的启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆