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.
How to put text in a drawable ? Basically, you have to extend the class Drawable and set the canvas to draw the text to a drawable. As you override the draw method, it will take the canvas and draw the text on defined locations.
Use multiple widgets if you need precise placement of discrete bits of text. Use inline markup if you, um, need markup inline in a widget. Remember: there is no FlowLayout in Android, so stringing together multiple TextViews to create a paragraph is not truly practical AFAIK.
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.
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