When you manually set the position of text relative to the picture, the following methods are commonly used:
Setcompounddrawables (left, top, right, bottom);
SetcompounddrawableswithIntrinsicbounds (left, top, right, bottom)
This means that the settings drawable appear in the left, top, right, and bottom positions of text.
(Textview, button all can)
But there are some differences:
The width height of the drawable of Setcompounddrawables is set by Drawable.setbound (), so the drawables must already has had setbounds (Rect) Called. means that you must use Drawable.setbounds to set the length and width of the drawable before use. And thesetcompounddrawableswith intrinsicbounds is painted drawable The wide height is fixed by the drawable of the wide height, that is, by Getintrinsicwidth () Obtained with Getintrinsicheight (), so only the drawables ' bounds will is set to their intrinsic bounds. That's the word! |
Android setcompounddrawableswithintrinsicbounds manually set text to picture relative position description