locked
MasterDetailPage icon right and drawer open from right to left RRS feed

  • Question

  • User368624 posted

    Hi How MasterDetailPage icon align to right? and how drawer open from right to left? Please give us code if you did it. Thank you

    Tuesday, June 5, 2018 1:56 PM

Answers

  • User368624 posted

    Yes I did it

    manifest :

    <application android:label="Sanaap" android:icon="@mipmap/launcher_foreground" android:theme="@style/MainTheme" android:supportsRtl="true">

    MainView.xaml

    <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="Sanaap.App.Views.MenuView" 
                 FlowDirection="RightToLeft"
                 Title="Main">
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 7, 2018 1:09 AM

All replies

  • User57571 posted

    Maybe this can help you: https://github.com/P3PPP/RightMasterDetailPageSample

    Tuesday, June 5, 2018 4:28 PM
  • User368624 posted

    Thank you 15mgm15 this sample creates MyMasterDetailPageRenderer in android project : public class MyMasterDetailPageRenderer : MasterDetailPageRenderer { protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement) { base.OnElementChanged(oldElement, newElement);

                var fieldInfo = GetType().BaseType.GetField("_masterLayout", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                var _masterLayout = (ViewGroup)fieldInfo.GetValue(this);
                var lp = new DrawerLayout.LayoutParams(_masterLayout.LayoutParameters);
                lp.Gravity = (int)GravityFlags.Right;
                _masterLayout.LayoutParameters = lp;
            }
        }
    

    and use it in xamarin forms app.xaml : public App() { InitializeComponent();

                var mdp = new MasterDetailPage
                {
                    Master = new ContentPage
                    {
                        BackgroundColor = Color.Lime,
                        Title = "Master",
                        Content = new Label
                        {
                            Text = "MasterPage",
                            HorizontalTextAlignment = TextAlignment.Center,
                            VerticalTextAlignment = TextAlignment.Center,
                        },
                    },
                    Detail = new ContentPage
                    {
                        BackgroundColor = Color.Gray,
                        Title = "DetailPage",
                        Content = new Label
                        {
                            Text = "DetailPage",
                            HorizontalTextAlignment = TextAlignment.Center,
                            VerticalTextAlignment = TextAlignment.Center,
                        },
                    },
                };
    
                MainPage = mdp;
            }
    

    and only where is the icon on action bar? how can I add the icon and align it to the right?

    Tuesday, June 5, 2018 11:03 PM
  • User368624 posted

    we must drag and drop and there is no icon on action bar

    Tuesday, June 5, 2018 11:12 PM
  • User322157 posted

    @mammadkoma I hope you have solved this problem if not then check that you have assign page to the detail page in masterpagexaml.cs

    Wednesday, June 6, 2018 11:37 AM
  • User368624 posted

    xamarin forms is realy restricted and weak in UI.

    Wednesday, June 6, 2018 11:41 AM
  • User368624 posted

    Yes I did it

    manifest :

    <application android:label="Sanaap" android:icon="@mipmap/launcher_foreground" android:theme="@style/MainTheme" android:supportsRtl="true">

    MainView.xaml

    <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="Sanaap.App.Views.MenuView" 
                 FlowDirection="RightToLeft"
                 Title="Main">
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 7, 2018 1:09 AM
  • User368624 posted

    But this forum has vary errors to post text

    Thursday, June 7, 2018 1:09 AM
  • User354661 posted

    @mammadkoma
    What About is Icon, it's dont move between right to left

    Thursday, November 29, 2018 3:39 PM
  • User382174 posted

    @MohanadAbusbib You should create a NavigationPageRenderer class in android and set toolbar layoutdirection to RTL

    Wednesday, February 20, 2019 12:56 PM
  • User378073 posted

    Anyone figure this out on iOS

    Tuesday, August 18, 2020 12:45 PM