I\'ve tried several different approaches, including the one found here (which in turn led me to trying both of the top answers to this question), as well as using reflection
Kotlin solution to set MARQUEE for both Title and Subtitle TextViews (it just finds all TextViews inside Toolbar):
findViewById(R.id.action_bar)?.let {
setToolbarTextViewsMarquee(it)
}
fun setToolbarTextViewsMarquee(toolbar: Toolbar) {
for (child in toolbar.children) {
if (child is TextView) {
setMarquee(child)
}
}
}
fun setMarquee(textView: TextView) {
textView.ellipsize = TextUtils.TruncateAt.MARQUEE
textView.isSelected = true
textView.marqueeRepeatLimit = -1
}
So it's not necessary to add Toolbar view (android.support.v7.widget.Toolbar or androidx.appcompat.widget.Toolbar) to xml layout
You can use the default Toolbar which AppCompat theme automatically adds: