using System; using Android.Content; using Android.Service.Autofill; using Android.Views.Accessibility; using CustomViewAccessibility.Droid; using SampleApp.CustomRenderers; using Xamarin.Forms; using Xamarin.Forms.Platform.Android; [assembly: ExportRenderer(typeof(FocusEvents), typeof(AndroidFocusEvents))] namespace CustomViewAccessibility.Droid { public class AndroidFocusEvents : ImageRenderer { Context context; public AndroidFocusEvents(Context context) : base(context) { this.context = context; } protected override void OnElementChanged(ElementChangedEventArgs e) { base.OnElementChanged(e); if (Control == null) { return; } } protected override Android.Widget.ImageView CreateNativeControl() { return new AccessibleButton(context); } } public class AccessibleButton : Android.Widget.ImageView { public AccessibleButton(Context context) : base(context) { Console.WriteLine("***** AccessibleButton created *****"); } public override void OnInitializeAccessibilityEvent(AccessibilityEvent e) { base.OnInitializeAccessibilityEvent(e); if (e.EventType == EventTypes.ViewAccessibilityFocused) { Console.WriteLine("ACCESSIBILITY I am in focus"); } else if (e.EventType == EventTypes.ViewAccessibilityFocusCleared) { Console.WriteLine("ACCESSIBILITY I am in NOT in focus"); } } } }