Android 中的可刮刮票类型自定义视图项目?
我需要开发一个即开彩票游戏应用程序。
我需要一个想法/程序来实现类似于 Android 中的即时彩票的 Scratchable 自定义小部件。
要求是,实际内容(秘密数字)应该被一些图像(指示草稿区域)覆盖。当用户触摸并刮擦图像时,图像必须缓慢消失,背景内容(秘密数字)应相应出现。
请让我知道实现此目的的最佳方法。我真的很需要它。
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从概念上讲,您可以将暂存区域(图像)放在最初隐藏的数字之上。当用户在草稿区域上执行动作时,更改草稿区域的不透明度,使其随着每次动作而消失。
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.
由于您不希望整个
View
改变其透明度,而只想改变其触摸的部分,因此需要在Canvas
上手动绘制,因此将 PorterDuff 模式设置为Paint
对象:以及使用
Color.TRANSPARENT
进行draw
另请参阅 Android 开发人员组中的此主题:http://groups.google.com/group/ android-developers/browse_thread/thread/5b0a498664b17aa0/de4aab6fb7e97e38?lnk=gst&q=erase+transparent#
Since you don't want the entire
View
to change its transparency, but only the touched parts of it, you need to draw manually on theCanvas
, set the PorterDuff mode on aPaint
object:and
draw
withColor.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#