I need to add drawable to my button and added drawableLeft to it. If button’s width is set to wrap_content, then everything is fine and looks good. But if I set custom width to my button then drawableLeft image goes away from button’s caption to left edge of the button. Is this somekind of a design bug in android? How can I fix this to let button look the same on custom width?
Regards,
evilone
Seems that x-position of the
drawableLeftdepends on left padding and x-scroll position: source. So that’s by-design behavior. I think you’d better useSpannableStringandImageSpanclasses to display an image to the left of the button’s text:Also, you can use
Html.fromHtml()method to buildSpannablefrom HTML. But in this case you need to implementHtml.ImageGetterinterface to load images from resources.EDIT: There’s a way to do a button-like widget using only XML: