views:

60

answers:

2

Hi All, I need to develop a Instant Lottery game app.

I need an idea/procedure to implement Scratchable custom widget similar to instant Lottery Tickets in Android.

The requirement is like, the actual content(secret number) should be covered by some image(which indicates scratch area). When the user touch and scratch the image, the image has to disappear slowly and the background content(secret number) should appear accordingly.

Please let me know the best way to implement this. I am in real need of it.

Thanks in advance.

+2  A: 

Conceptually, you could put your scratch area (image) on top of the number you're initially hiding. When the user performs motions on the scratch area, change the opacity of the scratch area so it fades away with every motion.

Jan Kuboschek
Hi, Thanks for the reply. I am trying in the same way as you mentioned. I am using Frame layout with 2 views one top of another. The scratch area is ImageView. I am not getting, how to make the touch area transparent? Can you help me in this? Thanks in advance. Do I need to raise another question for this separately.
Andhravaala
Jan Kuboschek
A: 

Since you don't want the entire view to change it's transparency, but only the touched parts of it, you need to draw manually on the canvas, set the PorterDuff mode on a Paint object:

mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)) 

and draw with Color.TRANSPARENT

Also see this thread in the Android developer group: http://groups.google.com/group/android-developers/browse_thread/thread/5b0a498664b17aa0/de4aab6fb7e97e38?lnk=gst&q=erase+transparent#

Mathias Lin