Created
November 4, 2019 21:02
-
-
Save grndvl1/57150b22f724006bb9303e25a161cc53 to your computer and use it in GitHub Desktop.
Marque Title of a Toolbar page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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