I have a image and I need to apply glow effect to center of the image using OnTouchListener
Something like this.
How can I achieve this effect? I have looked into examples where we can apply glow effect to outer part of the image.
We can achieve this by using a white image and place on top the background image, but can we do it without using images?
EDIT
I found this post as well but no solution.
Android : Image button or button Highlighted with Effect when Pressed
How about drawing a circle using
Then drawing the same circle over and over again at a slightly lesser alpha and bigger radius in a for loop?
Edit: Actually that sounds pretty bad for the memory but heck haven't tried it before.
On the
setOnTouchListener
get thegetDrawingCache()
of the image, Create a gradient bitmap of what you want and then overlay the images on top of one anotherTry this
Here is what I got
You can do your modifications here i have uploaded the project for you
Best of Luck
EDIT
To draw it at center use this line in the
overlay
methodAnd for adding bitmap to button use this
But note that when you set this bitmap to button the button will resize so better not use
wrap_content
but specify the height and width in hard code like25dp
or100dp
etc. That is the logic which you have to controlYou can also use ImageButton and set it as
For MotionEvent
EDIT 2
Declare these instance variables
and code the
onTouch
like thisYou can download the new updated project from here