Android TextView Display Incomplete auto-complement mode

Source: Internet
Author: User

There should be a lot of TextView used in Android development. Many times, TextView will have a line that is not completely intercepted or will be wrapped. Before my solution is clumsy, fixed dead textview line word length, the last one by ellipsis instead, this will have a lot of problems, the adaptation of Android phone is a headache problem. And the Chinese characters and English symbols occupy a different width, more headache. Find a way to be more simple and share. Android provides the Setellipsize method for TextView, which can help us save a lot of trouble. The specific practice is as follows:

textview.setellipsize (textutils.truncateat. MARQUEE);//have
Start end Middle Marquee parameter
Textview.setsingleline (TRUE);//Set as single-line
Textview.setmarqueerepeatlimit (6);//number of rolling cycles

Public static Finaltextutils.truncateatEND omitted

      public static final  textutils.truncateat  marquee   scrolling  
   

      public static final  textutils.truncateat  middle   Middle omitted

      public static final  textutils.truncateat  start
Start omitting

      If I want to be the lowest, I can do this:

       Setellipsize (TextUtils.TruncateAt.END);

But remember to set TextView as a single line. Android:singleline= "True" can be set in XML

Android TextView Display Incomplete auto-complement mode

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.