Android: Prevent keyboard navigation on entire view (Accessibility)

173 Views Asked by At

When a popup is opened, the view behind the popup can still be navigated using keyboard navigation.

Video attached to this github issue - https://github.com/rotorgames/Rg.Plugins.Popup/issues/728

From looking at the source code it adds an Android.View on top of the current Android.View. So need to away to prevent keyboard navigation focus of the original view and then enable it once the popup is closed.

1

There are 1 best solutions below

0
IeuanW On BEST ANSWER

Setting the ViewGroup DescendantFocusability to BlockDescendants while the popup is open, then setting it to AfterDescendants when the popup is closed.

Android doc - https://developer.android.com/reference/android/view/ViewGroup#attr_android:descendantFocusability

((ViewGroup)view).DescendantFocusability = DescendantFocusability.BlockDescendants;
((ViewGroup)view).DescendantFocusability = DescendantFocusability.AfterDescendants;

This is the PR that fixed the issue - https://github.com/LuckyDucko/Mopups/pull/23