Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove progress bar background in android progress bar

How do I remove the grey background and only display the blue progress strip in the progress bar.

enter image description here

like image 217
Karan Jit Singh Avatar asked Apr 19 '26 04:04

Karan Jit Singh


2 Answers

I have already answered a question with a similar requirement:


Result:

Result

To remove it, simply searching for the background by id and trying to hide it doesn't work. To remove the background, I had to create identical drawble of the system version and remove the background item.

TL;DR: Create file progress_horizontal_holo_no_background_light.xml and paste this drawable:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@android:id/secondaryProgress">
        <scale android:scaleWidth="100%"
               android:drawable="@drawable/progress_secondary_holo_light" />
    </item>

    <item android:id="@android:id/progress">
        <scale android:scaleWidth="100%"
               android:drawable="@drawable/progress_primary_holo_light" />
    </item>

</layer-list>

Copy appropriate .png drawables from sdk/platforms/android-xx/data/res/drawable-xxx/ to your project and then in the code you can add:

progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progress_horizontal_holo_no_background_light));

or set attribute in the xml file containing the ProgressBar

android:progressDrawable="@drawable/progress_horizontal_holo_no_background_light"
like image 63
Antimonit Avatar answered Apr 22 '26 00:04

Antimonit


<ProgressBar
    android:id="@+id/pb_timer"
    style="@style/Widget.AppCompat.ProgressBar.Horizontal"
    android:layout_width="0dp"
    android:layout_height="2dp"
    android:indeterminateTintMode="src_in"
    android:max="30000"
    android:progressTint="@color/color_primary_blue"
    android:rotation="180"
    android:secondaryProgress="30000"
    android:progressBackgroundTint="@color/background_color"
    android:secondaryProgressTint="@color/background_color"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/tv_mfa_type"
    tools:progress="15000" />

The key is these properties

android:progressBackgroundTint="@color/background_color"
android:secondaryProgressTint="@color/background_color"
like image 21
Pedro Romão Avatar answered Apr 22 '26 00:04

Pedro Romão



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!