0

I'm trying to make a button background, yet it appears somehow jagged.

enter image description here

public Bitmap makeButtonBit (int w,int h)
{

    Bitmap bitmapBtn = Bitmap.createBitmap(w, h+2, Bitmap.Config.ARGB_8888);
    Canvas cnvBtn = new Canvas(bitmapBtn);

    Paint pR1 = new Paint();
    pR1.setAntiAlias(true);
    pR1.setAlpha(40);
    ///

    RectF rectShd1 = new RectF(0, 0, w, h+1);
    cnvBtn.drawRoundRect(rectShd1, 8, 8, pR1);

    RectF rectShd2 = new RectF(0, 0, w, h+2);
    cnvBtn.drawRoundRect(rectShd2, 8, 8, pR1);
    ///
    pR1.setAlpha(255);
    pR1.setShader(new LinearGradient(0, 0, 0, h, 0x11000000, 0xCC000000, TileMode.CLAMP));
    RectF rect1 = new RectF(0, 0, w, h);
    cnvBtn.drawRoundRect(rect1, 6, 6, pR1);

    pR1.setShader(new LinearGradient(0, 0, 0, h, 0xFF858990, 0xFF2E3337, TileMode.CLAMP));
    RectF rect2 = new RectF(1, 1, w-1, h-1);
    cnvBtn.drawRoundRect(rect2, 6, 6, pR1);

    pR1.setShader(new LinearGradient(0, 0, 0, h, 0xFF525A63, 0xFF2D343A, TileMode.CLAMP));
    RectF rect3 = new RectF(2, 2, w-2, h-2);
    cnvBtn.drawRoundRect(rect3, 6, 6, pR1);

    return bitmapBtn;
}

Any ideas what am I doing wrong?

Thanks.

4

1 回答 1

1

你为什么不使用九个补丁?

于 2012-11-18T09:35:48.097 回答