What does ellipsize mean in android?

AndroidAndroid LayoutTextview

Android Problem Overview


I've added an EditText to my layout, and added a hint, and made it centered horizontally.

When running the application, the hint was invisible. I found that I should make ellipsize value of the TextView to be start:

<EditText
    android:id="@+id/number1EditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="start"
    android:ems="10"
    android:gravity="center_horizontal"
    android:hint="@string/hint1" />

In Android documentation, I read:

> If set, causes words that are longer than the view is wide to be
> ellipsized instead of broken in the middle.

The problem is that ellipsize is not found in the dictionary. Can anybody explain to me what benefits we can gain by ellipsize attribute? And what is the difference between start, end, middle?

Android Solutions


Solution 1 - Android

You can find documentation here.

Based on your requirement you can try according option.

to ellipsize, a neologism, means to shorten text using an ellipsis, i.e. three dots ... or more commonly ligature , to stand in for the omitted bits.

Say original value pf text view is aaabbbccc and its fitting inside the view

start's output will be : ...bccc

end's output will be : aaab...

middle's output will be : aa...cc

marquee's output will be : aaabbbccc auto sliding from right to left

Solution 2 - Android

In my experience, Ellipsis works only if the below two attributes are set.

android:ellipsize="end"
android:singleLine="true"

for the width of TextView, wrap_content or match_parent should both be good.

Solution 3 - Android

android:ellipsize added in API Level 1. An ellipsis is three periods in a row. (...) .

In your .xml

 <TextView
       ....
       android:text="Hi I am Amiyo, you can see how to ellipse works."
       android:ellipsize = "end" />

At this point, the ellipsis will not display yet as a TextView is set to automatically expand on default when new text is entered. You will need to limit TextView in some way. Do this, you can use either add to your TextView a scrollHorizontally, minLines, or maxLines to have the ellipsis display.

To make the ellipse:

    at the end: this is how it would.   
    use: android:ellipsize = "end"

And

 in the middle:
 use: android:ellipsize = "middle"

And

 at the start:
 use: android:ellipsize = "start"

And

 to have no ellipse
 use: android:ellipsize = "none"

Note Please :

Do not use android:singeLine = "true", it is deprecated.
android:maxLines = "1" will not display the three dots (...)
android:lines = "1" will not display the three dots (...)

For more details you can visit here

Solution 4 - Android

An ellipsis is three periods in a row...

The TextView will use an ellipsis when it cannot expand to show all of its text. The attribute ellipsized sets the position of the three dots if it is necessary.

Solution 5 - Android

Text:

 This is my first android application and
 I am trying to make a funny game,
 It seems android is really very easy to play.

Suppose above is your text and if you are using ellipsize's start attribute it will seen like this

This is my first android application and
...t seems android is really very easy to play.

with end attribute

 This is my first android application and
 I am trying to make a funny game,...

Solution 6 - Android

Here is an example on how ellipsize works without using deprecated android:singleLine="true" in a ConstraintLayout:

<TextView
   android:layout_width="0dp"
   android:layout_height="wrap_content"
   android:textSize="13sp"
   android:ellipsize="end"
   android:maxLines="2"
   app:layout_constraintEnd_toEndOf="parent"
   app:layout_constraintStart_toStartOf="parent"
   tools:text="long long long long long long text text text" />

remember if you have a text that is supposed to be in a single line, then change the maxLines to 1.

Solution 7 - Android

Note: your text must be larger than the container box for the following to marquee:

 android:ellipsize="marquee"	

Solution 8 - Android

Set this property to EditText. Ellipsize is working with disable EditText

android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
android:singleLine="true"
android:editable="false"

or setKeyListener(null);

Solution 9 - Android

Use ellipsize when you have fixed width, then it will automatically truncate the text & show the ellipsis at end,

it Won't work if you set layout_width as wrap_content & match_parent.

android:width="40dp"
android:ellipsize="end"
android:singleLine="true"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHamzeh SobohView Question on Stackoverflow
Solution 1 - AndroidRPBView Answer on Stackoverflow
Solution 2 - AndroidZephyrView Answer on Stackoverflow
Solution 3 - AndroidIntelliJ AmiyaView Answer on Stackoverflow
Solution 4 - AndroidSamView Answer on Stackoverflow
Solution 5 - AndroidsubodhView Answer on Stackoverflow
Solution 6 - AndroidMojAmiriView Answer on Stackoverflow
Solution 7 - AndroidksuView Answer on Stackoverflow
Solution 8 - AndroidMubarakView Answer on Stackoverflow
Solution 9 - AndroidMuthuraman SundararajView Answer on Stackoverflow