.NET MAUI 在两个 TabBar 之间切换时重绘动画

问题描述 投票:0回答:1
xamarin xamarin.android maui maui-shell
1个回答
0
投票

导航本身工作正常,但看起来 TabBar 正在开关上重新绘制并具有这种动画,它看起来很糟糕,特别是在黑暗模式下。此外,它的行为仅在 Android 上如此。 Windows 上没有这样的行为。我不知道iOS。

我测试了您提供的代码并重现了问题。我们尝试使用

Binding
INotifyPropertyChanged
来动态改变 TabBar 的
Visible
但以失败告终。它仍然有那种动画。您可以在MAUI问题GitHub上报告它。让我们的开发人员知道并处理它。

但是,如果您愿意尝试使用

TabbedPage
,它可以消除这种动画。您可以看到以下代码:

App.xaml.cs:

public partial class App : Application
{
    public static MyTabbedPage1 MyTabbedPage1;
    public static MyTabbedPage2 MyTabbedPage2;

    public App()
    {
        InitializeComponent();

        MainPage = MyTabbedPage1 = new MyTabbedPage1();
        MyTabbedPage2 = new MyTabbedPage2();
    }
}

我的选项卡页面1:

<TabbedPage  xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
             android:TabbedPage.ToolbarPlacement="Bottom"
             xmlns:view="clr-namespace:MauiApp2.Views"
             x:Class="MauiApp1.MyTabbedPage1"
             Title="MyTabbedPage1">

    <view:HomePage Title="Novinky" />
    <view:GroupListPage Title="Skupiny"/>
    <view:ProfilePage Title="Profil"/>
</TabbedPage>

我的选项卡页面2:

<TabbedPage  xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
             android:TabbedPage.ToolbarPlacement="Bottom"
             xmlns:view="clr-namespace:MauiApp2.Views"
             x:Class="MauiApp2.MyTabbedPage2"
             Title="MyTabbedPage2">

    <view:GroupPage Title="Oznámení" />
    <view:GroupTrialsPage Title="Testy"/>
    <view:GroupDetailPage Title="Detail"/>
</TabbedPage>

群组列表页面:

public partial class GroupListPage : ContentPage
{
    public GroupListPage()
    {
        InitializeComponent();
    }

    private async void Button_Clicked(object sender, EventArgs e)
    {
        App.Current.MainPage = App.MyTabbedPage2;
        await Navigation.PushAsync(new GroupPage());
    }
}

群组页面:

public partial class GroupPage : ContentPage
{
    public GroupPage()
    {
        InitializeComponent();
    }

    private async void Button_Clicked(object sender, EventArgs e)
    {
        App.Current.MainPage = App.MyTabbedPage1;
        await Navigation.PushAsync(new GroupListPage());
    }
}

这是effect

© www.soinside.com 2019 - 2024. All rights reserved.