I’m write a custom Drawable, a text over a bitmap:
@Override
public void draw(Canvas canvas) {
canvas.drawBitmap(badge, matrix, null);
canvas.drawText(count, size / 2, size / 2 + (text_size) / 2 , p);
}
When I use my drawable in an imageView, it’s fine.

But if I use this with a textview (compound drawable) it’s alignement is wrong.

I tried both setCompoundDrawablesWithIntrinsicBounds and setCompoundDrawables
Same results, what did I miss ?
Thanks.
I manage to get the right alignment (my drawable is a circle/square so width == height):
In my Custom_Drawable ctor:
onDraw method:
When setting the drawable :