I am setting contentDescription
to a toolbar in Fragment and DialogFragment class.
In Fragment
class, It works fine.
(e.g.
"toolbarContentDescription"
"Navigation Up"
In DialogFragment
class, It reads navigation up first.
(e.g.
"Navigation Up toolbarContentDescription"
"Navigation Up"
"toolbarContentDescription"
)I am using the same code to set toolbar in both classes.
I tried to fix it by changing the position of navigationContentDescription
. But it didn't work in dialogFragment class. and If I remove navigationContentDescription, on the back arrow it will read "Unlabeled Botton"
.
fun setToolBar(toolbar: Toolbar, title: String) {
getMainActivity().setSupportActionBar(toolbar)
toolbar.title = title
toolbar.contentDescription = "toolbar content description here"
toolbar.setTitleTextAppearance(context, R.style.white_toolbar_text)
toolbar.setBackgroundColor(ContextCompat.getColor(context, R.color.white))
toolbar.setNavigationIcon(R.drawable.ic_back_arrow)
// set back arrow content description.
toolbar.navigationContentDescription = "Navigation Up"
toolbar.setNavigationOnClickListener {
getMainActivity().onBackPressed()
}
toolbar.requestFocus()
toolbar.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
I don't understand the reason for this different behavior. It should read the same toolbar description as a fragment class in dialog fragment.
TalkBack
has a special treat to Dialog
screens. In every dialog, the screen reader makes a special announcement of its title. I don't think you will be able to change this behavior, since it is not in your app scope, but in the TalkBack
implementation itself.