3

我有这个文本视图

<TextView android:id="@+id/name"
          android:singleLine="true"
          android:layout_height="wrap_content"
          android:textColor="#ffffff" 
          android:textSize="16sp"  
          android:layout_width="fill_parent"/>

问题是如果文本更大然后文本视图可以显示它只是停止显示它看起来像这样|some unfinished tex|我想在最后有点这样它会让用户更清楚这是未完成并且它显示只是文本的一部分

我更喜欢这样的东西|Some unfinished te..|

如何实施?

4

3 回答 3

7

您是否尝试将android:ellipsize参数设置为“结束”?

于 2012-02-02T10:04:49.950 回答
0

每次我将其设置为 textview 并在文本子字符串之后附加这些点时,我都会通过检查文本大小来使用 hack。我不知道这是不好的做法!:P

于 2012-02-02T10:09:51.750 回答
0

你可以做这种类型;

public String getChar(String inputstring){
String substring;
if(inputstring.length() >0 ){
substring=inputstring.substring(int beginIndex, int endIndex);
}
StringBuilder sb=new StringBuilder(substring);
sb.append("....");
return sb.tostring();
}
于 2012-02-02T10:24:16.943 回答