A partial wrap for this Github project - do with it as you like.
Sample code:
Library:
FreeDrawView
Version: 1
Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aFreeDrawView
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\LibRes
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private fdv1 As FreeDrawView
Private btnRedo As Button
Private btnUndo As Button
Private btnUndoAll As Button
Private btnRedoAll As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
fdv1.PaintColor = Colors.Red
fdv1.PaintAlpha = 255
fdv1.PaintWidthDp = 5
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnRedo_Click
fdv1.redoLast
End Sub
Sub btnUndo_Click
fdv1.undoLast
End Sub
Sub btnUndoAll_Click
fdv1.undoAll
End Sub
Sub btnRedoAll_Click
fdv1.redoAll
End Sub
Library:
FreeDrawView
Version: 1
- FreeDrawView
Fields:- ba As BA
- 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)
- redoAll
Re-add all the removed paths and redraw - redoLast
Re-add the first removed path and redraw - undoAll
Remove all the paths and redraw (can be undone with {@link #redoLast()}) - undoLast
Cancel the last drawn segment
- Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- Left As Int
- PaintAlpha As Int [write only]
Set the paint opacity, must be between 0 and 1 - PaintColor As Int [write only]
- PaintWidthDp As Float [write only]
Set the paint width in dp - PaintWidthPx As Float [write only]
Set the paint width in px - Parent As Object [read only]
- RedoCount As Int [read only]
Get how many redo operations are available - Tag As Object
- Top As Int
- UndoCount As Int [read only]
Get how many undo operations are available - Visible As Boolean
- Width As Int