Set TextView/Button in android

Source: Internet
Author: User

In ApiDemo of Android, there is a Button drive effect, but it is still a little different if it is changed to TextView.

 


Define Marquee, mainly in Project/res/layout/main. xml

[Html]
<SPAN style = "COLOR: #993300"> <TextView
Android: layout_width = "40px"
Android: layout_height = "wrap_content"
Android: text = "Test marquee for TextView"
Android: layout_gravity = "center"
Android: ellipsize = "marquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: marqueeRepeatLimit = "marquee_forever"
Android: focusableInTouchMode = "true"
Android: scrollHorizontally = "true"
/> </SPAN>

<TextView
Android: layout_width = "40px"
Android: layout_height = "wrap_content"
Android: text = "Test marquee for TextView"
Android: layout_gravity = "center"
Android: ellipsize = "marquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: marqueeRepeatLimit = "marquee_forever"
Android: focusableInTouchMode = "true"
Android: scrollHorizontally = "true"
/>

 


Key points:
(1) The length set by layout_width is shorter than the actual length of text, that is, layout_width does not show all text before it will have the effect of riding a horse.
(2) ellipsize indicates that marquee is used
(3) singleLine indicates single row display
(4) marqueeRepeatLimit indicates the number of drive lights displayed: marquee_forever-unlimited uninterrupted display

[Html]
<SPAN style = "COLOR: #993300"> <Button

 
Android: id = "@ + id/buttonMarquee"
Android: layout_width = "320px"
Android: layout_height = "wrap_content"
Android: text = "@ string/textMarquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: selectAllOnFocus = "true"
Android: ellipsize = "marquee"
Android: marqueeRepeatLimit = "marquee_forever"
/> </SPAN>

<Button
 

Android: id = "@ + id/buttonMarquee"
Android: layout_width = "320px"
Android: layout_height = "wrap_content"
Android: text = "@ string/textMarquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: selectAllOnFocus = "true"
Android: ellipsize = "marquee"
Android: marqueeRepeatLimit = "marquee_forever"
/>

 

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.