B4A Library [B4X] [XUI] Animated Counter

Better implementation is included in XUI Views library.

animated_counter.gif


Class supported by B4i, B4A and B4J.

The animation is very smooth (smoother than in the above animated gif).

The class is available inside the attached B4J project.
And depends on: XUI, JavaObject libraries.
 

Attachments

  • AnimatedCounter.zip
    3.5 KB · Views: 762
Last edited:

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
A quick question... I've noticed that for projects such as this (and, for example, the "wheel" class example) you have chosen to include a PNG file that is a simple gradient as part of the class.

Since it is a just simple gradient, is there a reason you include it as an actual file rather than just creating it on-the-fly? I would think a completely self-encapsulated class would be preferable to one that relies on an external file being present would it not? Or is there some overhead or procedural reason to make a separate file and include it to which I'm unaware?
 
Last edited:

Jack Cole

Well-Known Member
Licensed User
Longtime User
This is very useful. I highly recommend this for any countdown timers on Android. It looks good and it shows up as performing very quickly in Google's metrics that are used for Android vitals. This solves several problems for me. Thanks!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Since it is a just simple gradient, is there a reason you include it as an actual file rather than just creating it on-the-fly?
Creating a gradient in B4J and B4i requires some non-trivial work so I preferred to use an image. The complete view was developed in less than 30 minutes as a response to a member question...
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Creating a gradient in B4J and B4i requires some non-trivial work so I preferred to use an image.
Fair enough, it's quite trivial to do in B4A and .NET, I just assumed it would be as easy to do in B4J/i as well. Just happy to know the choice is strictly a design concern, thanks for letting me know.

in less than 30 minutes
I'm pretty sure you do more by 8am than I do all day :p
 

Alexander Stolte

Expert
Licensed User
Longtime User
with BitmapCreator is a "Type do not match" on:
B4X:
Private Sub CreateFadeBitmap As B4XBitmap
    Dim bc As BitmapCreator
    bc.Initialize(200, 50)
    For x = 0 To bc.mWidth - 1
        For y = 0 To bc.mHeight / 2 - 1
            Dim a As Float = Max(0, 1 - y / bc.mHeight * 3)
            bc.SetARGB(a, x, y, 255, 255, 255)
            bc.SetARGB(a, x, bc.mHeight - 1 - y, 255, 255, 255)
        Next
    Next
    Return bc.Bitmap
End Sub

B4X:
bc.SetARGB(a, x, y, 255, 255, 255)
bc.SetARGB(a, x, bc.mHeight - 1 - y, 255, 255, 255)
 
Top