If you have enabled the navigation page, with the back button (the "<" icon) and the title, when the screen reader focus is on the back button it read "unlabeled button". Is there a way to change is Accessibility name to a proper "back button" or whatever else? Either in Android and iOS
Try to create page custom renderer to get the toolbar and set the Accessibility.
[assembly: ExportRenderer(typeof(ContentPage), typeof(NavigationPageRendererDroid))] namespace App1.Droid { public class NavigationPageRendererDroid : PageRenderer { public NavigationPageRendererDroid(Context context) : base(context) { } protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Page> e) { base.OnElementChanged(e); var context = (Activity)Xamarin.Forms.Forms.Context; var toolbar = context.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); toolbar.AnnounceForAccessibility(""); } } }
Answers
On Navigation pages, for Android, set the
AutomationProperties.Name
&AutomationProperties.HelpText
in order to enable the back button to be screen readable.Tutorial:
https://www.mfractor.com/blogs/news/accessibility-in-xamarin-forms
Yes I know how to set the accessibility name, I just don't know how to set it to the back button in navbar, since it is not an instance, I don't know how to retrieve this "backbutton" element
Try to create page custom renderer to get the toolbar and set the Accessibility.
I have the same problem about "unlabeled button". Is it possible to get back button reference from xamarin.forms? There is no way to do it without programming in android project?
Another way that I figured out is by creating my own navbar view, using
NavigationPage.SetTitleView(this, myCustonNavbar)
, in which I insert my ount back button with my own Accessibility nameAnd using the accepted answer, how do you set accessibility properties for the back button?
In the accepted answer you are using custom renderers. So when you are on the Android custom renderer you use the Android C# method to set the accessible name of a View, which is
View.ContentDescription
(https://docs.microsoft.com/en-us/dotnet/api/android.views.view.contentdescription?view=xamarin-android-sdk-9#Android_Views_View_ContentDescription), and when you are on the iOS custom renderer you use the iOS C# methodUIView.AccessibilityLabel
(https://docs.microsoft.com/it-it/dotnet/api/uikit.uiview.accessibilitylabel?view=xamarin-ios-sdk-12#UIKit_UIView_AccessibilityLabel)Thank you Poli97, NavigationContentDescription property is what I needed! So in OnElementChanged():
I didn't do it in that way but I think it should work too, in this way you have to get the toolbar first, follow @Jarvan answer to do that
Yes, sure, I did it like this:
But, is there a way to get directly button's reference?
I don't thinks so, this is why in my project I ended up using NavigationPage.SetTitleView creating my own navbar view with my own button