次の方法で共有


Android での TabbedPage ページのスワイプ

この .NET Multi-Platform App UI (.NET MAUI) Android プラットフォーム固有の UI は、TabbedPage のページ間で水平方向の指ジェスチャでスワイプできるようにするために使用されます。 TabbedPage.IsSwipePagingEnabled 添付プロパティを boolean 値に設定することで、XAML で使用されます。

<TabbedPage ...
            xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
            android:TabbedPage.OffscreenPageLimit="2"
            android:TabbedPage.IsSwipePagingEnabled="true">
    ...
</TabbedPage>

または、Fluent API を使用して C# から使用することもできます。

using Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;
...

On<Microsoft.Maui.Controls.PlatformConfiguration.Android>()
    .SetOffscreenPageLimit(2)
    .SetIsSwipePagingEnabled(true);

Note

このプラットフォーム固有は、シェルベースのアプリのタブには影響しません。

TabbedPage.On<Microsoft.Maui.Controls.PlatformConfiguration.Android> メソッドは、このプラットフォーム固有が Android でのみ実行されるように指定します。 Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific 名前空間の TabbedPage.SetIsSwipePagingEnabled メソッドは、TabbedPage のページ間でのスワイプを有効にするために使用します。 さらに、Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific 名前空間内の TabbedPage クラスには、このプラットフォーム固有を有効にする EnableSwipePaging メソッドと、このプラットフォーム固有を無効にする DisableSwipePaging メソッドもあります。 TabbedPage.OffscreenPageLimit 添付プロパティと SetOffscreenPageLimit メソッドは、現在のページの両側でアイドル状態で保持する必要があるページの数を設定するために使用されます。

結果として、TabbedPage によって表示されるページをページングするスワイプが有効になります。

Swipe paging through a TabbedPage.