Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android的奇怪问题:ellipsize =“end”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 android xml文件中使用android:ellipsize =“end”令人惊讶的是,我没有得到我想要的布局,3点(…)正在显示,但是在那个点之后,另外一个词被截断.这也是一个“不总是”的行为,检查附加的ListView,有时,行为是正常的&有时不是.

以下是我的设备的布局截图,

我不知道为什么会发生这种情况.这是我的xml文件,与tv_news_content TEXTView有问题 –

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://scheR_341_11845@as.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:BACkground="@color/white" >

<ImageView
    android:id="@+id/iv_@R_696_6777@ier"
    android:layout_width="18dp"
    android:layout_height="21dp"
    android:layout_alignParentright="true"
    android:layout_centerVertical="true"
    android:layout_marginRight="10dp"
    android:src="@drawable/right_arrow" >
</ImageView>

<TextView
    android:id="@+id/tv_news_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="7dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="3dp"
    android:layout_toLeftOf="@+id/iv_@R_696_6777@ier"
    android:ellipsize="end"
    android:maxLines="2"
    android:text="News title"
    android:textColor="@color/black"
    android:textSize="17dp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/tv_news_content"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/tv_news_title"
    android:layouT_Below="@+id/tv_news_title"
    android:layout_marginRight="5dp"
    android:layout_toLeftOf="@+id/iv_@R_696_6777@ier"
    android:ellipsize="end"
    android:maxLines="2"
    android:text="News Contents"
    android:textColor="@color/black_light"
    android:textSize="15dp" />

<View
    android:id="@+id/view"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layouT_Below="@+id/tv_news_content"
    android:layout_marginTop="5dp" />

为了使事情清晰,tv_news_title是最顶级的大胆的TextView,& iv_@R_696_6777@ier是右侧的小箭头ImageView. &安培; tv_news_content是我正面临的问题的TextView.

任何解决方案为什么我不希望输出?期望的输出意味着总是正常的行为 – 我想要在tv_news_content TEXTView的第二行末尾的3个点,而不是截断的单词之前.

任何建议是赞赏.

解决方法

当设置textview的文本时,确保文本不大于750个字符,因此在调用settext之前,请使用txt = theText.subString(0,750)或类似的内容.这适用于您的Feed的模拟器.并且应该是十英寸平板电脑的足够的字符

大佬总结

以上是大佬教程为你收集整理的android的奇怪问题:ellipsize =“end”全部内容,希望文章能够帮你解决android的奇怪问题:ellipsize =“end”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。