Skip to content Skip to sidebar Skip to footer

Android Button With Outer Glow

I know this topic has been discussed yet but I didn't find really what I wanna do. I have those buttons (screenshot at the bottom). Now I want to add a outer glow. Is there an oth

Solution 1:

try this code

public Bitmap setGlow(int resourceId) {
    Bitmapbmp=null;
    try {
        intmargin=30;
        inthalfMargin= margin / 2;

        intglowRadius=15;

        intglowColor= Color.rgb(0, 192, 200);

        Bitmapsrc= BitmapFactory.decodeResource(getResources(),
                resourceId);

        Bitmapalpha= src.extractAlpha();

        bmp = Bitmap.createBitmap(src.getWidth() + margin, src.getHeight()
                + margin, Bitmap.Config.ARGB_8888);

        Canvascanvas=newCanvas(bmp);

        Paintpaint=newPaint();
        paint.setColor(glowColor);

        paint.setMaskFilter(newBlurMaskFilter(glowRadius, Blur.OUTER));
        canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);

        canvas.drawBitmap(src, halfMargin, halfMargin, null);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return bmp;
}

and set the returned bitmap on your view

set in your imagebutton like this

btnClick.setImageBitmap(setGlow(R.drawable.ic_launcher));

Post a Comment for "Android Button With Outer Glow"