Implementation of multiple TextView lawn lights in Android self-learning notes
TextView:
1. Define four attributes of the textView Tag:
Android: singleLine = true // make it only have a single row
Android: ellipsize = marquee // remove the ellipsis
Android: focusable = true // loop it
Android: focusableInTouchMode = true
In this way, a TextVIew achieves the effect of running the horse lamp. However, if you write the second TextView in the same way, the second TextView will not work in actual operation, just like a normal TextView, the solution is as follows:
2. The custom class inherits TextView:
Implement three constructors;
Returns true when the isfocued method is rewritten. (by default, only one of them has focus on the first line)
@ Override
Public boolean isFocused (){
Return true;
}
In activity_main.xml, replace the custom class with TextView.
3. Use a custom class to replace TextView with the package name and custom Class Name (package name + class name under src)
The effect of running the horse lights is achieved.