DATEL:
DRIZDIK: Tak nakonec jsem použil řešení ze stack overflow, rozšířená třída Button s upravenou metodou onDraw(). Jen jsem tam opravil výpočet levé pozice ikonky:
// ------------------------------------------------------------------------------------------
// http://stackoverflow.com/a/15580164/2459448
private Drawable mLeftDrawable;
@Override
//Overriden to work only with a left drawable.
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
if (left == null) {
return;
}
left.setBounds(0, 0, (int) (left.getIntrinsicWidth()), (int) (left.getIntrinsicHeight()));
mLeftDrawable = left;
}
@Override
protected void onDraw(Canvas canvas) {
//transform the canvas so we can draw both image and text at center.
canvas.save();
canvas.translate(2 + (mLeftDrawable.getIntrinsicWidth()) / 2, 0);
super.onDraw(canvas);
canvas.restore();
canvas.save();
int widthOfText = (int) getPaint().measureText(getText().toString());
//int left = (int) ((getWidth() + widthOfText) / 2 - (mLeftDrawable.getIntrinsicWidth()) - 2);
int left = (int) ((getWidth() / 2) - (mLeftDrawable.getIntrinsicWidth() + widthOfText + 4) / 2);
canvas.translate(left, (getHeight() - (mLeftDrawable.getIntrinsicHeight())) / 2);
mLeftDrawable.draw(canvas);
canvas.restore();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int height = getMeasuredHeight();
height = Math.max(height, (int) ((mLeftDrawable.getIntrinsicHeight()) + getPaddingTop() + getPaddingBottom()));
setMeasuredDimension(getMeasuredWidth(), height);
}