I want to set the maximum value of a ProgressBar
in Android.
I know I can set the current progress with setProgress
or android:progress
, but how do I set the maximum value?
The maximum value of progress bar can be set by using max property value. Property Values: level: It returns the list of progress bar. max: It is used to set or return the progress bar value of max attribute.
setMax(int max_value)– It sets the maximum value of the progress in the progress bar. setProgress(int prog_val)– It updates the progress to the progress value that is passed in it. show(Context context, CharSequence title, CharSequence msg)– It displays the progress bar.
A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged.
By default, the progress bar is full when it reaches 100.
If necessary, you can adjust the maximum value (the value for a full bar) using the android:max attribute
android:max
Defines the maximum value the progress can take.
Must be an integer value, such as "100".
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
<ProgressBar
android:id="@+id/progressbar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:max="42" <--- it's the answer)
android:progress="0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_header_relativelayout"
/>
orprobressbar.setMax(Value);
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