Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to make an icon glow on touch?

How to get this blue glow effect over an icon? Is there any quick way of doing it? I really don't want to use photoshop for this effect.

Any help would be really appreciated.

like image 275
Varundroid Avatar asked Aug 28 '12 10:08

Varundroid


People also ask

How to create glow effect in Android?

I think there is no method in android to create glow effects. you have to make them yourself from scratch or find some java library that supports this.

How to change touch sensitivity on Android?

How to Change Touch Sensitivity on Android 1 Open your Android’s Settings. 2 Tap Languages & input. 3 Tap Pointer speed. 4 Drag the slider right to increase the sensitivity. 5 Drag the slider left to decrease sensitivity. 6 ... (more items) See More....

Can I change the size of icons and text on Android?

If you have trouble seeing things, you can adjust the size of icons, text, and more. We’ll show you how. Depending on what version of Android you’re using (and what type of phone), it’s possible that you may be able to change just the text size, or even make everything on the screen larger.

How do I speed up my touch screen on Android?

Steps Open your Android’s Settings. It’s the usually located on the home screen or in the app drawer. Tap Languages & input. It’s usually near the center of the menu. Tap Pointer speed. It’s under the “Mouse/trackpad” header. Drag the slider right to increase the sensitivity. This speeds up the screen’s reaction to your touch.


1 Answers

If you want to generate the glow programatically, here's how you can do. My advice, generate it just once at the beggining of your activity, then create a StateListDrawable using it, as said in the comment :

    // An added margin to the initial image
    int margin = 24;
    int halfMargin = margin / 2;

    // the glow radius
    int glowRadius = 16;

    // the glow color
    int glowColor = Color.rgb(0, 192, 255);

    // The original image to use
    Bitmap src = BitmapFactory.decodeResource(getResources(),
            R.drawable.ic_launcher);

    // extract the alpha from the source image
    Bitmap alpha = src.extractAlpha();

    // The output bitmap (with the icon + glow)
    Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,
            src.getHeight() + margin, Bitmap.Config.ARGB_8888);

    // The canvas to paint on the image
    Canvas canvas = new Canvas(bmp);

    Paint paint = new Paint();
    paint.setColor(glowColor);

    // outer glow
    paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER));
    canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);

    // original icon
    canvas.drawBitmap(src, halfMargin, halfMargin, null);

    ((ImageView) findViewById(R.id.bmpImg)).setImageBitmap(bmp);
like image 148
XGouchet Avatar answered Oct 13 '22 22:10

XGouchet