I am creating an app that will get numbers between 0-100 from the user, then getting the average and displaying it in a progress bar. For example the user enters 100, 80 and 75 the total is 255 and the average is 85 so i would like the progress bar to fill 3/4 of the circle and stop. At the moment the progress bar keeps spinning in circles and doesn't stop at the location I want even when I specify it with .setProgress(85)
. Could anybody help me out I'm quite stuck here's my code:
xml:
<ProgressBar
android:id="@+id/mProgressBar"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:rotation="-90"/>
java:
mProgressBar = (ProgressBar) findViewById(R.id.mProgressBar);
mProgressBar = new ProgressBar(ActivityA.this, null, android.R.attr.progressBarStyleLarge);
mProgressBar.setProgress(30);
mProgressBar.setMax(100);
You cannot do it with a simple progress bar.
Please take a look to this github or you might want to use a progress Dialog instead. Here is a good tutorial , easy to follow.
Ex :
barProgressDialog = new ProgressDialog(this);
barProgressDialog.setTitle("Downloading Image ...");
barProgressDialog.setMessage("Download in progress ...");
barProgressDialog.setProgressStyle(barProgressDialog.STYLE_HORIZONTAL);
barProgressDialog.setProgress(0);
barProgressDialog.setMax(20);
barProgressDialog.show();
This is pretty much what you want to do.
Hope it helps !
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.