Skip to content

Instantly share code, notes, and snippets.

Created November 4, 2019 21:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Marque Title of a Toolbar page
Most code I saw for this was to create custom layout. Project I did not want to do this but do it for only a specific activity. Here is how to do it in the activity in onStart()
override fun onStart() {
val toolbarViewGroup = findViewById<ViewGroup>( // standard action layout from theme
toolbarViewGroup?.let{ viewGroup ->
// find the textview title since its in combined layout
val textView = viewGroup.children.find { (it is TextView) } as TextView
textView.ellipsize = TextUtils.TruncateAt.MARQUEE
textView.marqueeRepeatLimit = 5
textView.isSelected = true // this is needed for marquee to work
XML for the activity did not have to be changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment