D
D
DARKENN2020-07-30 15:19:18
Java
DARKENN, 2020-07-30 15:19:18

How to make a circle countdown timer?

I tried to do something like this:

new CountDownTimer(11000, 1000) {
            @SuppressLint("SetTextI18n")
            public void onTick(long l) {
                donutProgress.setProgress(l/1000);
                text.setText(String.valueOf(l / 1000));

            public void onFinish() {
                text.setText("Готово");
        }.start();

donutProgress is a third party library that makes a circular progress bar.
This works in principle, but the progress bar turns out to be jerky, that is, there are no intermediate positions between integers.
I need something like this:
5f22ba7f2e340955441333.gif

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2020-08-01
@YuryBorodkin

You can use PropertyAnimation, changing the progress not immediately, but gradually for the widget.
For example, you need progress 30 - ObjectAnimator.ofInt(widget, "progress", 0..30).setDuration(100l).start()
If you want it yourself, Paint has a drawArc method. If you remember school geometry, you can write it in a couple of minutes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question