Search code examples
androidaccessibilityscreen-readerstalkback

Group Views for TalkBack


I have two TextViews. Currently, When Talkback is enabled, the user has to swipe twice to read both TextViews. But I want the screen reader to read the TextViews one after another without any user input (Like WhatsApp reading LastSeen and Chat name in one go). How can I achieve this? Any help would be appreciated


Solution

  • You can set the content description to the layout containing these two views and set individual views as not important for accessibility to combine them.

    For example:

    <LinearLayout …
      android:id="@+id/combinedLayout"
      android:contentDescription="Last seen / chat name"
      <TextView …
        android:text="Last seen"
        android:importantForAccessibility="no" />
      <TextView …
        android:text="Chat name"
        android:importantForAccessibility="no"/>
    </LinearLayout>
    

    Or in code it would be something like:

    combinedLayout.contentDescription = "add content description here"
    

    If any elements are clickable, be careful with setting as not important to accessibility, always test to make sure it behaves as you would expect.

    Check out my post about common accessibility issues :) https://medium.com/microsoft-mobile-engineering/android-accessibility-resolving-common-talkback-issues-3c45076bcdf6