LimGeomJe
LimGeomJe

Reputation: 215

how can i move hamburger menu to right side on maui android?

I am making android/ios app using maui. I want to move my hamburger button to right side.

this is my appshell.xaml.

<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="MauiSample.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:views="clr-namespace:MauiSample.Views"
    xmlns:local="clr-namespace:MauiSample"
    FlowDirection="RightToLeft">

    <FlyoutItem
        FlyoutDisplayOptions="AsMultipleItems">
        <ShellContent Title="Dog2s"
                            ContentTemplate="{DataTemplate views:DogsPage}" />
        <ShellContent Title="Monkeys"/>
        <ShellContent Title="Elephants"/>
        <ShellContent Title="Bears"/>
    </FlyoutItem>
    <ShellContent
        Title="Home 2"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />

</Shell>

I check added supportRtl="true" in android manifest. android:supportsRtl="true"

I used FlowDirection="RightToLeft".
but not working on android.
working on ios.

android

ios

Upvotes: 2

Views: 1036

Answers (1)

Jianwei Sun - MSFT
Jianwei Sun - MSFT

Reputation: 4332

Add this in your MainActivity.cs:

public class MainActivity : MauiAppCompatActivity
{    
    protected override void OnCreate(Bundle savedInstanceState)    
    {        
       base.OnCreate(savedInstanceState);        
       Window.DecorView.LayoutDirection = Android.Views.LayoutDirection.Rtl;    
    }
}

Upvotes: 3

Related Questions