Implementation of multiple TextView lawn lights in Android self-learning notes

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.