
我想将TextVIEw限制为2行.这是我的布局XML,有问题的TextVIEw是ID /描述:
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="vertical" androID:padding="8dp" ><TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="OBJEKTBESCHREIBUNG" androID:textAppearance="@style/LargeText" androID:textcolor="@color/myorange" /><VIEw androID:layout_wIDth="match_parent" androID:layout_height="1dp" androID:background="@color/myorange" /><TextVIEw androID:ID="@+ID/description" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="4dp" androID:maxlines="2" androID:ellipsize="end" androID:textAppearance="@style/StandardText" /><button androID:ID="@+ID/more" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Mehr ..." androID:textAppearance="@style/SmallText" /></linearLayout>文本在应有的位置处被省略了(请参见图片),但是下一个单词ist仍然可见.
是什么原因造成的?
编辑:这是我设置为TextVIEw的文本样式:
<style name="StandardText"> <item name="androID:FontFamily" tools:ignore="NewAPI">sans-serif-light</item> <item name="androID:textSize">15sp</item> <item name="androID:textcolor">#000000</item></style>Edit2:尝试删除textAppearance属性,但没有任何效果(关于椭圆尺寸的“ BUG”).
解决方法:
当您的输入文本恰好在应椭圆形区域中包含换行符或其他“特殊”字符时,就会出现此问题.
尝试使用:
text.replaceAll("(\t|\r?\n)", " ")这可能会解决您的问题.
总结以上是内存溢出为你收集整理的android-text:maxLines和text:ellipsize无法正常工作全部内容,希望文章能够帮你解决android-text:maxLines和text:ellipsize无法正常工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)