Android TextView the problem of overall shortening when setting the single-line maximum width and ellipsize ellipsis

Source: Internet
Author: User

In the TextView of Android

Also set

Android : Maxwidth= "155DP"
Android : lines= "1"
Android : ellipsize= "End"

When running on some phones, when the length of the TextView is more than 155DP, it will be found that the last displayed length does not reach 155DP, even the difference is very wide,

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= " Https://s5.51cto.com/wyfs02/M00/8D/9A/wKioL1ijyufQ3kFfAABZMhs4bLk772.png-wh_500x0-wm_3-wmp_4-s_2074796271.png " Title= "4zd@ (0o0c}5dak%4) jaa[cq.png" alt= "Wkiol1ijyufq3kffaabzmhs4blk772.png-wh_50"/>


Workaround:

Put

android:lines= "1"

Replaced by

Android:singleline= "true"

That

Android : Maxwidth= "155DP"
Android : singleline= "true"
Android : ellipsize= "End"

Get results

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8D/9A/wKioL1ijzCfxY9FgAABTyPCTRHw929.png-wh_500x0-wm_ 3-wmp_4-s_706553173.png "title=" $FDDOJ 6dmt@]tm~5s_rc_ft.png "alt=" Wkiol1ijzcfxy9fgaabtypctrhw929.png-wh_50 "/>

Android TextView the problem of overall shortening when setting the single-line maximum width and ellipsize ellipsis

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.