简体   繁体   中英

How to start a progressbar at a certain position in a stop/play animation? [Xamarin forms]

progressBar.Animate("SetProgress", (arg) => {

     System.Diagnostics.Debug.WriteLine(arg); // 0.00 - 1.00 is the value
     progressBar.Progress = arg;

}, 1, 5000, Easing.Linear, 
(v, c) => progressBar.Progress = 0);  // when finished, reset

this is what i use to stop my progressbar (works fine)

progressBar.AbortAnimation("SetProgress");

So the progressbar starts from 0 each time when i make the animation. Now i want to start it from a certain time. So lets say from second 3 out of 500ms (5sec).

I then do this, progressBar.Progress = 0.3; above the animation. The progressbar still starts from 0 sec either way.

What can i do to start the timer a certain time out of this set 5 sec period?

try something like this to set the initial value of the animation

var animation = new Animation (v => progressBar.Progress = v, 0.3, 1);

animation.Commit (this, "SimpleAnimation", 16, 2000, Easing.Linear, (v, c) => image.Scale = 1, () => false);

to cancel

this.AbortAnimation ("SimpleAnimation");

You can use a "custom" animation:

double totalTime = 5000;
double startTime = 3000;
var animation = new Animation(v => progress.Progress = v, startTime/totalTime, 1, Easing.Linear);
animation.Commit(this, "LinearProgressFromTime", 16, (uint)(totalTime - startTime) , Easing.Linear, (v, c) => progress.Progress = 1, () => false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM