B4A Library CompassView

The attached project wraps this Github project. The library files are in the /files folder of the attached B4A project. Copy them to your additional library folder. Also posting the Java code. You will also need to enable the Phone library in the B4A project. Move your device in different directions and see the compasses changing accordingly.


Johan Schoeman
Version: 1
  • CompassView
    • 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)
    • Background As Drawable
    • Color As Int [write only]
    • CompassBackgroundColor As Int [write only]
    • CompassDegrees As Float [write only]
    • CompassLineColor As Int [write only]
    • CompassMarkerColor As Int [write only]
    • CompassRangeDegrees As Float [write only]
    • CompassShowMarker As Boolean [write only]
    • CompassTextColor As Int [write only]
    • CompassTextSize As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int


  • JavaCode.zip
    27.8 KB · Views: 409
  • b4aCompassView.zip
    31.1 KB · Views: 455

Johan Schoeman

Licensed User
Longtime User

Johan Schoeman

Licensed User
Longtime User
I would be very happy to use some of your libraries in my app. Where can I donate ?
Hey guys i think it's right to make a small donation to colleagues as @Johan Schoeman ,@DonManfred, etc. It is very fair because they give us many beautiful libraries.
I wait your notice Johan.
Thank you again for your great work
I am doing this purely for the fun of it @MarcoRome. You can use whatever you want (of what I have posted) in your apps. No need to donate anything. My "payment" is the satisfaction of seeing it "work"....;)


Licensed User
Longtime User
Just a note:

You do not need a device that supports phone sensors (PhoneOrientation - as my tablets do not).

I use it with GPS.
compass1.CompassDegrees = Location1.Bearing

This works perfectly well - setting the compass to show your current heading.

Thanks for this wrap.