Adam
Adam

Reputation: 862

android circle progressbar

I need to make a circle progress bar, which rotate only while data is receiving. I wrote in layout:

        <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminateOnly="true"
            style="?android:attr/progressBarStyleSmall"
            />

And then the part of data was received, I do

mProgressBar.incrementProgressBy(10);

I thought that initially mProgressBar should be stopped, but it is rotating permanently, even than connection is not established!

What should I do to make ProgressBar initially stopped & and rotating while another part of data was received?

Upvotes: 3

Views: 10497

Answers (4)

user1567667
user1567667

Reputation:

Use visible and gone for visibility in the layout.

Upvotes: 1

Chitranshu Asthana
Chitranshu Asthana

Reputation: 1089

There is no way to stop indeterminate progress bar. Either you will have to create your own custom progress bar or you can do small tricks with indeterminate drawable.

You can have an imageview over progress bar and set the same drawable in it.

When you want to stop the animation, hide progress bar and show image view.

When you want to start animation, hide image view and show progress bar.

It should give you same effect.

Upvotes: 5

Anton
Anton

Reputation: 4403

Sorry, but you can't achieve that with indeterminate progress bar. The control is made to show that something is being performed in background. With no indication on when did this operation start or when will it finish.

So you either have to user determinate progress bar, or create your own custom component

Upvotes: 0

Kanaiya Katarmal
Kanaiya Katarmal

Reputation: 6118

call this line when you work done.

 mProgressBar.dismiss();

Upvotes: 0

Related Questions