Android Question Live update direction arrow

MotoMusher

Active Member
Licensed User
Longtime User
Looking for best practices here. I have a GPS application. I would like to add a direction arrow based off of heading to target.

What would be the most efficient method to do this? My first thought is an imageview updated every second in a timer based on a case statement of 36 images, each handling 10 degrees.

Would there be a more efficient way to do this?
 

eurojam

Well-Known Member
Licensed User
Longtime User
I would take a panel, then draw a needle (bitmap) or something on it and use an Animation to rotate it ...here are some fragments, which I used in a similar App:
B4X:
bmpNeedle.Initialize(File.DirAssets, "needle.png")
panNeedle.Initialize("")
panNeedle.setBackgroundimage(bmpNeedle)
...
Rotation.InitializeRotateCenter("Animation", 0, 0, panNeedle) 'Initialize the Animation
Rotation.Duration = 20000

'and later in the change direction event or in the timer:
'where t is the angle 
        Rotation.InitializeRotateCenter("Animation", t, t, panNeedle)
        Rotation.Duration = 20000   
         Rotation.Start(panNeedle)
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
For such simple graphics i place an ImageView und draw the arrow with ABExtDrawing lib.
As in my current project (see arrow on right top of the map).
Karte_01.jpg

The round buttons on the left top and right bottom are also drawn and no bitmaps.
 
Upvote 0
Top