Using the new r21 appcompat library, I wanted to show an indeterminate (spinning) progress bar in the Toolbar.
Previously, using the < r21 appcompat library, it worked, but it seems that there is no implementation of the progress bar in r21. Am I right? Is there a way for this without creating a custom progress bar?
My onCreate method starts with:
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setSupportProgressBarIndeterminate(true);
setSupportProgressBarIndeterminateVisibility(true);
Indeterminate mode is the default for progress bar and shows a cyclic animation without a specific amount of progress indicated. The following example shows an indeterminate progress bar: <ProgressBar android:id="@+id/indeterminateBar" android:layout_width="wrap_content" android:layout_height="wrap_content" />
There are 2 types of progress bars: determinate and indeterminate. The former is used when the amount of information that needs to be loaded is detectable. The latter is used when the system is unsure how much needs to be loaded or how long it will take.
Go to the activity_main. xml file and refer to the following code. Open the activity_main. xml file and in the ProgressBar tag and set the drawable in indeterminateDrawable attribute.
In short: no, you have to create a custom progress bar in your Toolbar. Progress is not supported in action bars for 21+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With