I am setting contentDescription
to a toolbar in Fragment and DialogFragment class.
In Fragment
class, It works fine.
(e.g.
- on toolbar focused,
"toolbarContentDescription"
- on next swipe forward,
"Navigation Up"
- on next swipe backward, "toolbarContentDescription")
In DialogFragment
class, It reads navigation up first.
(e.g.
- on toolbar focused,
"Navigation Up toolbarContentDescription"
- on next swipe forward,
"Navigation Up"
- on next swipe backward,
"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.