Skip to content Skip to sidebar Skip to footer

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.

Solution 1:

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-listxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:id="@android:id/secondaryProgress"><scaleandroid:scaleWidth="100%"android:drawable="@drawable/progress_secondary_holo_light" /></item><itemandroid:id="@android:id/progress"><scaleandroid: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"

Solution 2:

<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"

Post a Comment for "Remove Progress Bar Background In Android Progress Bar"