Ellipsis is triple dots (...) at the end of the line. It is required when you want to keep your sentence in a single line. If your test reached the end of the line then automatically create ... at the end.
If you want a horizontal scrollable text in your app, use android:ellipsize="marquee" where a single line large text will be scrolling.
The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion.
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
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With