Android 为什么单行文本视图用“删除”;完";展示箱?
我在Android中使用一个TextView,我想在TextView中显示以“.”结尾的一行,但这会在末尾给出[]类型框。我不知道为什么?我只想删除这个框,只想显示以“…”结尾的文本 更新list_row.xml的代码Android 为什么单行文本视图用“删除”;完";展示箱?,android,android-layout,android-widget,Android,Android Layout,Android Widget,我在Android中使用一个TextView,我想在TextView中显示以“.”结尾的一行,但这会在末尾给出[]类型框。我不知道为什么?我只想删除这个框,只想显示以“…”结尾的文本 更新list_row.xml的代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_wid
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="85dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:cacheColorHint="#4C7B8D"
android:background="#4C7B8D">
<ImageView
android:id="@+id/videoListImage"
android:src="@drawable/audio_thumbnail60x60"
android:layout_height="75dp"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:layout_width="75dp"
android:padding="4dp"
android:background="@color/light_gray" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@+id/next_arrow"
android:orientation="vertical"
android:gravity="center_vertical"
android:paddingLeft = "5dp">
<TextView
android:id="@+id/row_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/app_background_color"
android:textSize="18sp"
android:ellipsize="end"
android:maxLines="1" />
<TextView
android:id="@+id/row_dis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/color_black"
android:layout_marginRight="2dp"
android:textSize="15sp"
android:ellipsize="end"
android:maxLines="1" />
<TextView
android:text="$7.50"
android:id="@+id/audio_price_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="@color/color_white"
android:textStyle = "bold"
android:paddingLeft = "12dp"
android:paddingRight = "12dp"
android:background="@drawable/blue_round_cornor_background" />
</LinearLayout>
<ImageView
android:id="@+id/next_arrow"
android:src="@drawable/next_arrow"
android:layout_toLeftOf="@+id/saved_purchased"
android:scaleType="fitXY"
android:layout_height="25dp"
android:layout_width="18dp"
android:layout_centerVertical="true"
android:visibility = "gone"/>
<ImageView
android:id="@+id/saved_purchased"
android:layout_alignParentRight="true"
android:layout_alignParentTop ="true"
android:scaleType="fitXY"
android:layout_height="25dp"
android:layout_width="25dp"
android:layout_marginRight="2dp"/>
</RelativeLayout>
下面是要显示的实际描述字符串
Andrew和Stephanie Tidwell坦率地分享了他们在这一行业的成功故事。这个故事将帮助每个听众认识到,没有人是完美的,即使在第二代企业中也是如此。这是一个流式音频文件
还有什么问题吗?我可以更新更多问题。Arslan,您的布局在我的情况下运行良好,我已通过以下测试:
<TextView
android:id="@+id/row_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="18sp"
android:ellipsize="end"
android:maxLines="1"
android:text="This is the demo testing demo testing This is the demo testing demo testing"/>
。。。并获得您想要的准确输出“一行以…”结尾”和框应被删除。因此,我认为您设置的任何字符或文本都可能有问题。引用自己的话:
Android的TextView类内置了“省略”文本的功能,
如果文本长度超过可用长度,则截断并添加省略号
空间例如,您可以通过android:ellipsize属性使用它。
至少对于单行文本来说,这是非常有效的。
Android使用的省略号不是三个句号。而是使用实际的
省略号字符,其中三个点包含在单个字形中。
因此,使用“省略号”功能的任何字体都将
需要省略号符号
不过,除此之外,Android会填充屏幕上呈现的字符串,使得前后的长度(以字符为单位)相同
“省略”。为了实现这一点,Android将一个字符替换为
省略号,并用Unicode替换所有其他删除的字符
字符“零宽度不间断空格”(U+FEFF)。这意味着
省略号后面的“额外”字符不会占用屏幕上的任何可见空间
屏幕,但它们可以是字符串的一部分
但是,这意味着您为TextView小部件使用的任何自定义字体
您与android一起使用:ellipsize还必须支持这种特殊的Unicode
性格并不是所有的字体都这样,你会在屏幕上看到工件
如果字体缺少此字符,则表示缩短的字符串
(例如,rogue X出现在行的末尾)
当我尝试使用自定义的“MetaPro media.otf”作为
TextView
的字体时,遇到了同样的问题
android:singleLine=“true”
。
绳子末端的盒子真让人讨厌
我在Android中找不到解决这个问题的方法,但同时发现了以下解决方法
textview.settext(content);
到
工作正常。事实上,我遇到了这个问题,我没有更改字体或使用setText,而是将scroll水平添加为false,并修复了额外的框字符
android:singleLine="true"
android:scrollHorizontally="false"
android:ellipsize="end"
我在项目中遇到了一个类似的问题,在项目中,我在文本视图中使用了字体类型。很少有字体类型有这样的问题,使。。。最后显示为[]。如果您尝试更改字体,问题就会解决。我看您的布局没有任何问题。TextView的值来自哪里?不知何故,你的字符串上是否有回车/换行标志?哦,是的,这可能是个问题。。。我不想考虑。如何解决?请尝试将
String.replaceAll(“\r\n”,”)
应用于您的字符串。谢谢您的时间。让我再检查一下。我认为“>”图像可能会造成问题。非常感谢您抽出时间。我得到了它。但如何解决这个问题呢?你解决了吗?@Arslan:使用内置字体。或者,修复字体以包含缺少的U+FEFF图示符。或者,使用已经有此标志符号的字体。@Manu iAndyDev:是,我更改了字体。你也可以使用内置字体。不知道为什么这对我不起作用。是否有任何特殊的时间设置文本视图是否在onCreate中?在我重新编译后,此解决方案似乎不起作用。有效的方法是不使用省略号。到目前为止,我找到的唯一方法就是编辑字体。我没有Fontlab工作室,也付不起900美元。因此,我现在将删除它,稍后制作我自己的ellipsize版本。
textview.settext(Html.fromHtml(content));
android:singleLine="true"
android:scrollHorizontally="false"
android:ellipsize="end"