Android: why isn't setPadding being respected?
<p>I am trying to set the background of a Button to a PaintDrawable which I am creating in code.  This works pretty well, but my Button appears larger than an android.view.Button.  </p>

<p>In the below image, the first Button is an instance of MyButton, the second button is an instance of android.widget.Button. </p>

<p>I tried both setting the padding on the PaintDrawable and MyButton, but neither has any noticeable effect.</p>

<p><img src="http://i.stack.imgur.com/Se4H8.png" alt="enter image description here"></p>

<pre><code>public class MyButton extends Button
{
    PaintDrawable drawable = null; 

    public ColorButton(Context context)
    {
        super(context);

        drawable = new PaintDrawable();
        drawable.getPaint().setColor(Color.WHITE);
        drawable.setCornerRadius(1);

        //neither of these seem to do anything?
        drawable.setPadding(10, 10, 10, 10);
        setPadding(10, 10, 10, 10);

        setBackgroundDrawable(drawable);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) 
    {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        //set gradient in here, because getWidth/getHeight are useless prior to this
        drawable.getPaint().setShader(new LinearGradient(getMeasuredWidth()/2, 0, getMeasuredWidth()/2, getMeasuredHeight(), Color.WHITE, Color.GRAY, Shader.TileMode.MIRROR));
    }
}
</code></pre>
