B4A Library Android-Water-Gauge

A wrap for this Github project. Download the attached zipped files. Extract LibRes.zip and then copy the folder with its contents to be on the same folder level as that of the /Files and /Objects folders of the B4A project.

Copy the library files to your additional library folder. Also make sure that you have AppCompat V3.51 in your additional library folder and that it is enabled in the IDE library tab

1.png


2.png


Library:
WaterGauge
Author:
Github: Mehmet, Wrapped by: Johan Schoeman
Version: 1
  • WaterGauge
    Events:
    • value_changed (value As String)
    Fields:
    • ORIENTATION_HORIZONTAL As Int
    • ORIENTATION_VERTICAL As Int
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String, orientation As Int)
    • 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)
    • acceptabilityChanged (view As OrientationFeedbackView, acceptable As Boolean)
    Properties:
    • AcceptedBallColor As Int [write only]
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • GaugeBackgroundColor As Int [write only]
    • GaugeLineColor As Int [write only]
    • GaugeLineWidth As Int [write only]
    • GaugeRange As Int [write only]
    • GaugeTextColor As Int [write only]
    • GaugeTextSize As Int [write only]
    • Height As Int
    • Left As Int
    • Orientation As Int [write only]
    • Padding()() As Int
    • Parent As Object [read only]
    • RejectedBallColor As Int [write only]
    • Tag As Object
    • Threshold As Double [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aWaterGauge
    #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 wg1 As WaterGauge
    Private wg2 As WaterGauge
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

    wg1.Initialize("wg1", wg1.ORIENTATION_VERTICAL)
    Activity.AddView(wg1,5%x, 5%y, 20%x, 60%y)
    wg1.GaugeTextColor = Colors.Black
    wg1.GaugeTextSize = 20
    wg1.AcceptedBallColor = Colors.green
    wg1.RejectedBallColor = Colors.Magenta
    wg1.GaugeBackgroundColor = Colors.LightGray
    wg1.GaugeLineColor = Colors.yellow
    wg1.GaugeLineWidth = 3
    wg1.GaugeRange = 90
    wg1.Threshold = 20
    
    wg2.Initialize("wg2", wg2.ORIENTATION_HORIZONTAL)
    Activity.AddView(wg2,5%x, 70%y, 90%x, 15%y)
    wg2.GaugeTextColor = Colors.White
    wg2.GaugeTextSize = 15
    wg2.AcceptedBallColor = Colors.Cyan
    wg2.RejectedBallColor = Colors.White
    wg2.GaugeBackgroundColor = Colors.Gray
    wg2.GaugeLineColor = Colors.Black
    wg2.GaugeLineWidth = 3
    wg2.GaugeRange = 90
    wg2.Threshold = 15

   

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub wg1_value_changed (degree As String)
   
    Log("wg1 = " & degree)
   
End Sub

Sub wg2_value_changed (degree As String)
   
    Log("wg2 = " & degree)
   
End Sub

Note: You can only add it via code and NOT via the designer.
 

Attachments

  • LibRes.zip
    744 bytes · Views: 377
  • b4aWaterGauge.zip
    7 KB · Views: 359
  • LibraryFiles.zip
    33 KB · Views: 393

AHilton

Active Member
Licensed User
Longtime User
Also called a Bubble Gauge or Bubble Level. (For helping those searching for those words in the forum search)
 
Top