与Android奇怪的问题:ellipsize ="末" [英] Strange issue with android:ellipsize="end"

查看:145
本文介绍了与Android奇怪的问题:ellipsize ="末"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的安卓ellipsize =结束在Android的xml文件,和放大器;令人惊讶的我没有得到我想要的,三个点(...)都出现了布局,但那个圆点之后还有另外一个词截断。另外这是一个不总是的行为,检查连接ListView的,有时候,是正常现象和放大器;有时没有。

I am using android:ellipsize="end" in android xml file, & surprisingly I am not getting the layout that I want, the 3 dots(...) are showing but after that dots there is another word truncated. Also this is a "not-always" behavior, check the ListView attached, sometimes, the behavior is normal & sometimes not.

这里的布局,从我的设备的屏幕截图,

Here's the screenshot of the layout from my device,

我没有任何想法,为什么这种情况正在发生。这是我的XML文件,有问题在 tv_news_content 的TextView -

I don't have any idea why this is happening. Here's my xml file, having problem with the tv_news_content TextView -

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

<ImageView
    android:id="@+id/iv_next_tier"
    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_next_tier"
    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_next_tier"
    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_next_tier 是小箭头型的ImageView在右边。 &放大器; tv_news_content 是我现在面临的问题与TextView的。

To make things clear, tv_news_title is the topmost bold TextView, & iv_next_tier is the small arrow-type ImageView at the right. & tv_news_content is the TextView that I am facing problem with.

为什么我没有得到期望的输出任何解决办法?所需的输出意味着总是正常的行为 - 我想这3个点在第二行中的 tv_news_content TextView的,而不是被截断字之前

Any solution why I am not getting desired output? Desired output means the always normal behaviour - I want those 3 dots at the end of second line of tv_news_content TextView, not before a truncated word.

任何建议是AP preciated。

Any suggestion is appreciated.

推荐答案

在设置文本的TextView确保文字不超过750个字符,以便使用TXT = theText.substring(0,750)或者类似的东西在调用的setText。这适用于您的饲料模拟器。而且应该是足够的字符为10寸平板电脑太

When setting the text for the textview make sure the text is not greater than 750 characters so use txt = theText.substring(0, 750) or something like that before calling settext. This works on the emulator with your feed. and should be enough characters for a 10inch tablet too

这篇关于与Android奇怪的问题:ellipsize =&QUOT;末&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆