Chuyên mục
Internet

Circular Determinate ProgressBar with Background and Text – Android Studio Tutorial

Rate this post



In this tutorial, we will learn how to create a circular progress bar in Android Studio that displays the current progress value and has a gray background color.

Tag: progress bar android, [vid_tags]

Xem thêm: https://meohay360.com/category/internet

Nguồn: https://meohay360.com

29 trả lời trong “Circular Determinate ProgressBar with Background and Text – Android Studio Tutorial”

found just what i needed – thanks for the great video.
i am trying to sync the progress with a countdowntimer but am having some trouble doing so.

the snippet of relative code is:
ProgressBar progressBar;

int progr = 100;

public void startTimer() {

countDownTimer = new CountDownTimer((timerLength * 1000) + 100, 1000) {

@Override

public void onTick(long l) {

updateTimer((int) l / 1000);

updateProgressBar();

}

@Override

public void onFinish() {

Log.i("timer", "finished");

timerTextView.setText(String.valueOf(timerLength));

}

}.start();

}

//pause timer when pressed the timerTextView

public void updateTimer(int secondsLeft) {

Log.i("time set to", Integer.toString(secondsLeft));

timerTextView.setText(Integer.toString(secondsLeft));

}

private void updateProgressBar() {

int timeLeftTV = parseInt(timerTextView.getText().toString());

progr = Math.round(timeLeftTV/timerLength * 100);

progressBar.setProgress(progr);

}

can you see where i am going wrong? the textview decreases by seconds and i tried to use that as a percentage for the progress. the colored progress bar shows at the start but on the first tick it just goes grey.

thanks for the help.

QUEDA MEJOR ASI, DESAPARECE UNA VEZ EMPIEZA LA WEBVIEW

JAVA:

public ProgressBar progressBar;

progressBar = (ProgressBar)findViewById(R.id.prg);

web.setWebViewClient(new MyWebViewClient(){

@Override public void onPageStarted(WebView view, String url, Bitmap favicon) {

super.onPageStarted(view, url, favicon);

progressBar.setVisibility(View.GONE);

setTitle("Loading…");

}

});

XML:

<WebView

android:id="@+id/openmerquiverduras"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_constraintTop_toTopOf="parent"

tools:layout_editor_absoluteX="210dp" >

</WebView>

<ProgressBar

android:layout_width="60dp"

android:layout_height="60dp"

style="@style/Widget.AppCompat.ProgressBar"

android:layout_centerHorizontal="true"

android:layout_centerInParent="true"

android:indeterminateTint="@color/colorPrimaryDark"

android:id="@+id/prg"

/>

Hello Sir, I have tried this with Java in android studio but facing a problem. The color or gradient and rotation is not working. I have tried but its showing a circular progress bar with primary color Green. So i change the color values of primary color but its does reflect changes still its showing progressbar in green. Can you tell me what is the problem?

Trả lời

Email của bạn sẽ không được hiển thị công khai.