Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change android progress bar thickness

this should be a very easy to customize style...

i want a horizontal progress bar that is slithly thick (or that i can customize the thickness) and the color matches the apps color

if i do

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:layout_below="@id/textLoading"
    android:layout_centerHorizontal="true"
    android:indeterminate="true"
     />

the progress bar is horizontal and matches app visual identity... but is too thin... the person need glases to see it

if i do

<ProgressBar
        android:id="@+id/progressBar"
        style="android:Widget.ProgressBar.Horizontal"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_below="@id/textLoading"
        android:layout_centerHorizontal="true"
        android:indeterminate="true"
         />

the progress bar is good thickness but the color is a stupid yellow that matches nothing in this plannet

how can i customize individual parameters???

like image 639
Rafael Lima Avatar asked May 08 '20 01:05

Rafael Lima


1 Answers

there are many ways to achieve what you need:

1- use android:scaleY="8" in your XML file

or from code

mProgressBar.setScaleY(3f);

2- style="@android:style/Widget.ProgressBar.Horizontal" this will make you have Horizontal progress bar, so you can inherit it in styles and edit it as follows:

<style name="CustomProgressBarHorizontal" parent="android:Widget.ProgressBar.Horizontal">
      <item name="android:progressDrawable">@drawable/custom_progress_bar_horizontal</item>
      <item name="android:minHeight">10dp</item>
      <item name="android:maxHeight">20dp</item>
</style>
like image 150
Moustafa EL-Saghier Avatar answered Nov 08 '22 14:11

Moustafa EL-Saghier