The attached B4A project wraps this Github project. It is rounded check boxes with a very nice animation. Posting the B4A project, the B4A library files, and the Java Code. The library has a callback to the B4A project where you can pick up the status of the checkbox (true / false = checked / unchecked).
Caught the animation with this screenshot
Some sample code:
AnimCheckBox
Author: Johan Schoeman
Version: 1
Caught the animation with this screenshot
Some sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: AnimCheckBox
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#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 acb1, acb2, acb3, acb4, acb5 As AnimCheckBox
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")
acb1.StrokeWidth = 2
acb1.TickColor = Colors.Blue 'the color of the tick mark when checked
acb1.InnerCircleColor = Colors.black
acb1.InnerCircleAlpha = 255
acb1.CheckedOuterCircleColor = Colors.Blue 'this is outer circle color when checked
acb1.OuterCircleAlpha = 100 'when checked
acb1.UncheckedOuterCircleColor = Colors.Blue 'unchecked outer circle color
Log("acb1 status = " & acb1.isCheckBoxChecked)
acb2.StrokeWidth = 7
acb2.TickColor = Colors.Black 'the color of the tick mark when checked
acb2.InnerCircleColor = Colors.DarkGray
acb2.InnerCircleAlpha = 255
acb2.CheckedOuterCircleColor = Colors.Red 'this is outer circle color when checked
acb2.OuterCircleAlpha = 50 'when checked
acb2.UncheckedOuterCircleColor = Colors.Green 'unchecked outer circle color
Log("acb2 status = " & acb2.isCheckBoxChecked)
acb3.StrokeWidth = 5
acb3.TickColor = Colors.White 'the color of the tick mark when checked
acb3.InnerCircleColor = Colors.Blue
acb3.InnerCircleAlpha = 200
acb3.CheckedOuterCircleColor = Colors.Yellow 'this is outer circle color when checked
acb3.OuterCircleAlpha = 255 'when checked
acb3.UncheckedOuterCircleColor = Colors.Magenta 'unchecked outer circle color
Log("acb3 status = " & acb3.isCheckBoxChecked)
acb4.StrokeWidth = 10
acb4.TickColor = Colors.Green 'the color of the tick mark when checked
acb4.InnerCircleColor = Colors.Black
acb4.InnerCircleAlpha = 255
acb4.CheckedOuterCircleColor = Colors.White 'this is outer circle color when checked
acb4.OuterCircleAlpha = 255 'when checked
acb4.UncheckedOuterCircleColor = Colors.White 'unchecked outer circle color
Log("acb4 status = " & acb4.isCheckBoxChecked)
acb5.StrokeWidth = 15
acb5.TickColor = Colors.Yellow 'the color of the tick mark when checked
acb5.InnerCircleColor = Colors.Black
acb5.InnerCircleAlpha = 255
acb5.CheckedOuterCircleColor = Colors.Yellow 'this is outer circle color when checked
acb5.OuterCircleAlpha = 255 'when checked
acb5.UncheckedOuterCircleColor = Colors.White 'unchecked outer circle color
Log("acb5 status = " & acb5.isCheckBoxChecked)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub acb1_check_changed
Log("acb1 status = " & acb1.isCheckBoxChecked)
End Sub
Sub acb2_check_changed
Log("acb2 status = " & acb2.isCheckBoxChecked)
End Sub
Sub acb3_check_changed
Log("acb3 status = " & acb3.isCheckBoxChecked)
If acb3.isCheckBoxChecked = False Then acb3.InnerCircleColor = Colors.Black
If acb3.isCheckBoxChecked = True Then acb3.InnerCircleColor = Colors.Blue
End Sub
Sub acb4_check_changed
Log("acb4 status = " & acb4.isCheckBoxChecked)
If acb4.isCheckBoxChecked = False Then acb4.InnerCircleColor = Colors.Red
If acb4.isCheckBoxChecked = True Then acb4.InnerCircleColor = Colors.Black
End Sub
Sub acb5_check_changed
Log("acb5 status = " & acb5.isCheckBoxChecked)
If acb5.isCheckBoxChecked = False Then acb5.UncheckedOuterCircleColor = Colors.Magenta
If acb5.isCheckBoxChecked = True Then acb5.CheckedOuterCircleColor = Colors.Yellow
End Sub
AnimCheckBox
Author: Johan Schoeman
Version: 1
- AnimCheckBox
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)
- isCheckBoxChecked As Boolean
- setChecked (checked As Boolean, animation As Boolean)
checked true if checked, false if unchecked
animation true with animation,false without animation
- Background As Drawable
- Checked As Boolean [write only]
setChecked with Animation
checked true if checked, false if unchecked - CheckedOuterCircleColor As Int [write only]
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- InnerCircleAlpha As Int [write only]
- InnerCircleColor As Int [write only]
- Left As Int
- OuterCircleAlpha As Int [write only]
- StrokeWidth As Int [write only]
- Tag As Object
- TickColor As Int [write only]
- Top As Int
- UncheckedOuterCircleColor As Int [write only]
- Visible As Boolean
- Width As Int
Attachments
Last edited: