Skip to content

Instantly share code, notes, and snippets.

@grndvl1
Created November 4, 2019 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grndvl1/57150b22f724006bb9303e25a161cc53 to your computer and use it in GitHub Desktop.
Save grndvl1/57150b22f724006bb9303e25a161cc53 to your computer and use it in GitHub Desktop.
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() {
super.onStart()
val toolbarViewGroup = findViewById<ViewGroup>(R.id.action_bar) // 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