Android Question How can i set max valu in circular progress bar ?

mr.gedo

Member
Thank you for your replay @Erel

please look at the project below

I don't mean that the value moves automatically but I mean to set the maximum value without move so I can move it by click on the (+) button

the max value of the progress bar is 100 by default but I need to change the maximum value of the progress bar to less or more than 100

For example, if I set the maximum value to 500 I need when I click on the (+) button the value move one step every click until the value reaches 500, the circular bar is complete

hope you understand me

Best Regards
 

Attachments

  • Speed Track.zip
    12.5 KB · Views: 93
Upvote 0

MikeSW17

Active Member
Licensed User
Couldn't you scale the value rather than changing the maximum? Something like:

B4X:
Private Sub Button6_Click
    SetProgress(1000, 0.1)
End Sub

Sub SetProgress(Value As Int, Scale As Double)
    CircularProgressBar1.Value = (Value * Scale)
End Sub
 
Upvote 0

mr.gedo

Member
Hello, thank you for your replay

I just need to set maximum value and change the value manually
I made a virtual code so you can understand me
please see the video below

 

Attachments

  • Speed Track-2.zip
    12.8 KB · Views: 104
Upvote 0

mr.gedo

Member
It seems that's no solution to set the maximum value, so I'll keep searching to find an alternative solution

thank you very much
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
You will have to modify this a little. It does most of the job but you have to be prepared to do some coding to get exactly what you want.

Just tap the screen in the area of the progress display to set a value. The subroutine displayProgress(pcnt) draws the progress bar as a percentage value. The "touch_Touch" subroutine detects screen tap positions and converts them to percentage values. The "external scaling" value (0-500 for your case), is set in the last line.

I have extracted this code from a project of my own, but I have not tidied it up very much. If it is what you are looking for but you need more information then let me know, but I am hoping that you can adapt it into exactly what you want.
 

Attachments

  • Progress500.zip
    10.2 KB · Views: 88
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I'm not sure I can edit this code

Okay, then let's go back to @MikeSW17 's suggestion and modify Erel's code. In fact that is a much more sensible option - I should have done it in the first place

Here is Erel's original download with the progress bar "value" parameter scaled to 1-500 rather than 1-100. Just use this library instead of the original one.

For information, the only changes needed in the library are ...

B4X:
Public Sub setValue(NewValue As Float)
    NewValue = NewValue / 5                ' <<<< New line
    AnimateValueTo(NewValue)
End Sub

and ...

B4X:
    mLbl.Text = $"$1.0{Value * 5}"$            ' " * 5" added
 

Attachments

  • Circular500.zip
    9.5 KB · Views: 139
Upvote 0

Ivan Aldaz

Member
Licensed User
Longtime User
Hi, I needed the same and worked on Erel's code to get it.

You can set max value in the Designer and by code, and can also change colors, size, duration and stroke by code.

Hope it's what you are looking for.

Best regards

EDIT:
- Added 'SetLayout' method. This way it is easier to position the view and the label is presented correctly. In my previous version it wasn't when the layout was modified.
- Added 'AnimationType' property, that can be set in Designer and code. Ease-In Ease-Out animation isn't fine sometimes, e.g. with temporizers. It's easy to add more animations, just by looking at the code and visiting the page provided by Erel: http://gizma.com/easing/
- Can change label TextColor, Typeface and TextSize by code
 

Attachments

  • CircularProgressBarModified.bas
    6.9 KB · Views: 96
Last edited:
Upvote 0
Top