Limit the size of the textview horizontally
-
21-04-2021 - |
Question
I have this text view
<TextView android:id="@+id/name"
android:singleLine="true"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="16sp"
android:layout_width="fill_parent"/>
The problem is if the text is bigger then the textview can display it just stop displaying it looks something like this |some unfinished tex|
I want to have dots on the end in this way it will be more clear to the user that this is unfinished and it it is displayed only a part of the text
I would prefer something like this |Some unfinished te..|
How to implement this ?
Solution
Have you tried setting android:ellipsize paremeter to "end"?
OTHER TIPS
I used the hack by checking text size every time i set it to textview and appended those dots after a substring of text.I don't know it is bad practice or so!! :P
you can do this type;
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();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow