Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
where is the difference between
TextView
's methods to set drawable? Documentation is quite vague.
1) setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom)
2) setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable end, Drawable bottom)
3) setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
4) setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top, Drawable end, Drawable bottom)
Thanks in advance.
setCompoundDrawables
requires you to call setBounds(Rect)
on the Drawable
(s) manually, whereas setCompoundDrawablesWithIntrinsicBounds
will determine the bounds of the Drawable
for you (kind of like setting an ImageView
to wrap_content
).
setCompoundDrawablesRelative
is identical to setCompoundDrawables
, except rather than using "left" and "right", it uses "start" and "end", which is useful if you want to support both left-to-right and right-to-left localizations (see this blog post for more info). Same applies to setCompoundDrawablesRelativeWithIntrinsicBounds
and setCompoundDrawablesWithIntrinsicBounds
.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.