Accessibility TalkBack not working on progressBar

Viewed 40

I am adding Accessibility in my Android app and it seems not working properly for the progressBar. Any time, I display the progress bar, I want to have talk back saying something so, I did this in the xml:

android:importantForAccessibility="yes"
android:contentDescription="Loading"
android:visibility="gone"

and, programmatically, I am doing this :

collectState(viewModel.loading) { loading ->
            binding.progressBar.isVisible = loading
            binding.progressBar.isFocusable = loading
            binding.progressBar.isClickable = loading
        }

So when the loading state is collected, I am making the viewModel focusable and visible if loading is true.

But it's not working at all, it still not saying anything.

Any idea why? Thanks

1 Answers

As long as you use android:visibility="gone" it will be ignored by the TalkBack, it will be treated as an element that will be hidden visually and to the Screen Reader. So, suppose you want to have a hidden element that announces the 'Loading' process or progress of the 'Loading' process. In that case, you could make it simple by using a live region available in android and updating its content as long as the process gets completed (i.e. Loading 1%, 50%, and so on). Refer to: https://mobilea11y.com/blog/android-live-regions/

To consider:

  • If a progress bar is used, you could keep it visible and ensure its focus once the process has been started, so you could update its android:contentDescription attribute with the progress percent.
  • Use a visual indicator as a spinner or a TextView with the progress description (i.e. Loading 1%, 50%, and so on) that presents the android:liveRegion='polite'

Hope this helps in your a11y journey

Related