B4A Library ScratchView V1.5

This is a wrap for this github project.

V1.5 needs B4A 6+ as the resources are now inside an aar.

ScratchView
Author:
DonManfred (wrapper)
Version: 1.5
  • ScratchImageView
    Events:
    • PercentRevealed (percent As Double)
    • onRevealed ( As )
    • onScratching (Scratched As Boolean)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • clear
      clears the scratch area to reveal the hidden image.
    • isRevealed As Boolean
    • setEraserMode
    Properties:
    • Background As Drawable
    • Color As Int
    • Enabled As Boolean
    • ErasePaint As Paint [read only]
    • Height As Int
    • ImageBounds() As Int [read only]
    • ImageDrawable As Drawable [write only]
    • ImageResource As String [write only]
    • Left As Int
    • Parent As Object [read only]
    • StrokeWidth As Int [write only]
      Set the strokes width based on the parameter multiplier.
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • ScratchTextView
    Events:
    • PercentRevealed (percent As Double)
    • onRevealed ( As )
    • onScratching (Scratched As Boolean)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • isRevealed As Boolean
    • reveal
      Reveals the hidden text by erasing the scratch area.
    Properties:
    • Background As Drawable
    • Color As Int
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • StrokeWidth As Int [write only]
      Set the strokes width based on the parameter multiplier.
    • Tag As Object
    • Text As String
    • TextColor As Int [write only]
    • TextColor2 As ColorStateList
    • TextSize As Float
    • Top As Int
    • Visible As Boolean
    • Width As Int

scratch_image_view_demo.gif
scratch_text_view_demo.gif
 

Attachments

  • ScratchViewV1.0.0.zip
    19 KB · Views: 341
  • ScratchViewV1.0.1.zip
    19.6 KB · Views: 337
  • ScratchViewV1.2.zip
    20.6 KB · Views: 379
  • ScratchViewEx.zip
    13.7 KB · Views: 438
  • ScratchViewV1.5.zip
    33.7 KB · Views: 656
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
:) VERY NICE!!! THANK YOU!!! :)
 

DonManfred

Expert
Licensed User
Longtime User
:) VERY NICE!!! THANK YOU!!! :)
:D

This wrap has more functionality as the wrapped lib was. The Original does only have a event when you reveal the hole object.... I thought it would be nice to have an additional event when you do your first scratch on one of the scratchitems.... The onScratching event was born :)
My example shows this
 

udg

Expert
Licensed User
Longtime User
Very very nice, Manfred.
Scratching effect was applied to one of my first apps..eventually it could be re-tooled with your lib!
 

MarcoRome

Expert
Licensed User
Longtime User
Great work Don ( as usual ;) ) +40
Look this 2 little demo:
In this first movie as i "touch" but i dont see Text in ( 0$, 1$ or 5$ ) o_O

if i write ScratchTextView1.Text i dont see this in code but i see in Design.
P.S. You forget in your demo donmanfred.png
 

DonManfred

Expert
Licensed User
Longtime User

LucaMs

Expert
Licensed User
Longtime User
I should "test" it (to know the differences); anyway, I did something like this... probably 2 years ago and... not for me :p

It was a "Gratta e Vinci" (Scratch and win)
steve-hildebran-plays-a-scratch-and-win-game-in-his-surrey-b-c-home.jpg


This is just to say: "Unfortunately at the time there was not this library" ;)
 

DonManfred

Expert
Licensed User
Longtime User
"PercentageRevealed event" is feature very important for this library.
I missed this feature and told about in b4achatroom...

- I got a suggestion from @NJDude for a library which does have such a feature.
- I tried to make a wrap for it till i saw it does not work. But i copied the code from it which does the calculation and i extended this lib with the code from the other lib. It works!

V1.2 was born :D
 

Keith Flanagan

Member
Licensed User
Hi,

I get the following error when using the example ScratchViewEx with ScratchViewV1.5 Library, i have copied the jar,xml and aar into my additional libraries folder.

When compiling i get the following error:

B4A version: 6.31
Parsing code. (0.00s)
Compiling code. (0.03s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.04s)
Compiling debugger engine code. (0.58s)
Compiling generated Java code. Error
Cannot find: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\android-support-v4.jar
 

DonManfred

Expert
Licensed User
Longtime User

DaniDPX

Member
Licensed User
I missed this feature and told about in b4achatroom...

- I got a suggestion from @NJDude for a library which does have such a feature.
- I tried to make a wrap for it till i saw it does not work. But i copied the code from it which does the calculation and i extended this lib with the code from the other lib. It works!

V1.2 was born :D

@DonManfred Am aware that this thread is old but am kindly wanted to ask that PercentRevealed fixed on v1.5? It is not working for me here..

Regards;
 
Top