What does ellipsize mean in android?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Android, ellipsize controls how a TextView shortens text that does not fit in the available display area. Instead of letting the text overflow or wrap forever, Android can replace part of the text with an ellipsis so the most useful portion remains visible.
What ellipsize Actually Does
The term comes from "ellipsis," meaning the three-dot truncation marker. In Android, it tells a TextView where to place that truncation when the text is longer than the view can display.
A simple example:
With end, Android keeps the start of the text and truncates the tail with an ellipsis when needed.
Common ellipsize Modes
The most common values are:
- '
end' - '
start' - '
middle' - '
marquee'
Each changes where the hidden text is removed.
end is the most common and is usually right for titles or labels.
start keeps the end visible and hides the beginning, which can help when suffixes matter more than prefixes.
middle keeps both ends visible while cutting out the center, which is useful for file paths, hashes, or identifiers.
marquee scrolls the text instead of replacing the hidden portion with a static ellipsis.
Width and Line Count Matter
ellipsize only activates when the view is constrained. If the TextView is free to grow, there is nothing to truncate.
That is why ellipsize is usually combined with:
- a limited width
- '
maxLines="1"for single-line truncation' - sometimes
maxLinesgreater than one for controlled multi-line cases
Programmatically, the same idea looks like:
Without width or line constraints, it can look like ellipsize is broken when the layout simply has no reason to use it.
marquee Needs Extra Setup
marquee is the special case. It usually needs the view to be single-line and selected before the scrolling effect appears.
This catches many developers because setting only ellipsize="marquee" is often not enough.
Choosing the Right Mode
A practical rule is:
- use
endfor most normal labels - use
startwhen the suffix is more important than the prefix - use
middlefor technical strings where both ends matter - use
marqueesparingly because moving text can hurt readability
The correct choice depends on which part of the text the user needs most.
Programmatic Configuration
You do not have to set ellipsize only in XML. The same behavior can be configured in code:
This is useful when a screen changes its truncation strategy dynamically, such as showing full titles in one layout state and compact identifiers in another.
Common Pitfalls
Setting ellipsize without constraining width or line count leaves the view nothing to truncate, so the attribute appears ineffective.
Expecting marquee to work without extra setup is a common source of confusion because it requires more than just the XML value.
Choosing middle or start without thinking about readability can produce text that feels unnatural for ordinary titles.
Testing only with short sample strings can hide truncation issues that appear immediately with realistic production content.
Assuming ellipsize is about text wrapping rather than truncation leads to incorrect layout expectations.
Summary
- '
ellipsizecontrols how Android truncates text that does not fit.' - The common modes are
start,middle,end, andmarquee. - '
endis the usual choice for ordinary labels and titles.' - Width and line constraints are required for truncation to happen.
- '
marqueeneeds additional setup and should be used carefully.'

