The library disables the view behind the scratchable linear layout
Closed this issue · 2 comments
Due to this library, I could achieve the functionality what I wanted. But, the only issue which I could not find the reason why it happened is, It disables the layout that needs to be revealed and is enabled only when the threshold reached.
What I have done: (as explined in the README.md)
I created a RelativeLayout (to align layouts on top of one another) consisting of 2 sub-layouts, a behind-View and the View to be scratched away from the foreground.
The behind view contains a button ("Try again") which I want to be enabled.
That's actually part of how it's designed. If you look at line 95 in the ScratchoffController, you'll see we're setting an OnTouchListener
to the top layer, in order to resolve scratching motions.
If you checkout line 119, you'll see a return false
in the onTouch
method when scratching is disabled, telling the chain that it doesn't want to receive (read: block) touch events from passing through the View hierarchy. If you're editing the source and wanted to manually disable the ScratchoffController's touch blocking, you could simply expose a function that sets enabled = false
. Note: doing so would prevent scratching until re-enabled or reset.
I would recommend just using ScratchoffController.clear()
which would disabled the top layer (and fade out) to expose the functionality below. If you needed to hide UI components, you could do so prior to calling clear().
I found another solution to deal with the problem. I just made the button's visibility gone until the scratch reaches to the threshold and on completion callback I make the button's visibility visible.