B4A Library SpeedView

A Wrap for this Github project. Posting the following:

1. B4A sample project
2. B4A library files
3. Java Code - amend it to your liking.

Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: SpeedView
    #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.

    Dim t As Timer


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 sv1 As SpeedView
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")

    t.Initialize("t", 1000)

    sv1.IndicatorColor = Colors.White
    sv1.TextColor = Colors.White
    sv1.LowSpeedColor = Colors.Yellow
    sv1.MediumSpeedColor = Colors.Cyan
    sv1.HighSpeedColor = Colors.Magenta
    sv1.MaxSpeed = 200
    sv1.CenterCircleColor = Colors.Green
    sv1.MarkColor = Colors.Red
    sv1.WithTremble = False

End Sub

Sub Activity_Resume

    t.Enabled = True

End Sub

Sub Activity_Pause (UserClosed As Boolean)

    t.Enabled = False

End Sub

Sub t_tick

    sv1.speedTo_2(Rnd(0, 201), 400)

End Sub

Library:
SpeedView
Author:
Github: Anas Altair, Wrapped by: Johan Schoeman
Version: 1
  • SpeedView
    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)
    • speedPercentTo (percent As Int)
      change speed to percent value.
      percent percent value to change, should be between [0,100].
    • speedTo_1 (speed As Int)
      if speed is less than 0 then speed will be 0.
      speed correct speed to move.
    • speedTo_2 (speed As Int, moveDuration As Long)
      speed correct speed to move.
      moveDuration The length of the animation, in milliseconds. This value cannot be negative.
    Properties:
    • Background As Drawable
    • CenterCircleColor As Int [write only]
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • HighSpeedColor As Int [write only]
    • IndicatorColor As Int [write only]
    • Left As Int
    • LowSpeedColor As Int [write only]
    • MarkColor As Int [write only]
    • MaxSpeed As Int [write only]
    • MediumSpeedColor As Int [write only]
    • Parent As Object [read only]
    • SpeedTextSize As Float [write only]
    • SpeedometerWidth As Float [write only]
    • Tag As Object
    • TextColor As Int [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
    • WithTremble As Boolean [write only]

1.gif
 

Attachments

  • b4aSpeedView.zip
    7.8 KB · Views: 215
  • SpeedViewLibFiles.zip
    11.5 KB · Views: 214
  • TheJavaCode.zip
    5.7 KB · Views: 209
Last edited:
Top