Search code examples
androidxamarin.formsmaster-pagestalkback

Xamarin.Forms + Master Detail + TalkBack on Androind


I made custom renderer for NavigationPageRenderer but I cant change the burger menu button ContentDescription. It reads burger menu button as "OK" button. Do you have some ideas?


Solution

  • It's a ImageButton in Android platform. So you can change the image source of this hamburger button to implement this feature.

    You could use Custom Renderers to create a custom MasterDetailPage, here is an example:

    [assembly: ExportRenderer(typeof(MasterDetailPage), typeof(MyMasterDetailRenderer))]
    ...
    public class MyMasterDetailRenderer : MasterDetailPageRenderer
    {
        public MyMasterDetailRenderer(Context context) : base(context)
        {
        }
    
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            for (var i = 0; i < toolbar.ChildCount; i++)
            {
                var imageButton = toolbar.GetChildAt(i) as ImageButton;
    
                var drawerArrow = imageButton?.Drawable as DrawerArrowDrawable;
                if (drawerArrow == null)
                    continue;
    
                imageButton.SetImageDrawable(Context.GetDrawable(Resource.Mipmap.hamburger));
            }
        }
    }