How do I remove the grey background and only display the blue progress strip in the progress bar.
Asked
Active
Viewed 4,787 times
3
-
see http://stackoverflow.com/questions/16893209/how-to-customize-a-progress-bar-in-android – Rachel Gallen Jun 15 '14 at 20:00
-
That is not what I want. I want the native holo progress bar just without the background. – Karan Jit Singh Jun 15 '14 at 20:02
-
you still have to customise the progress bar. just change the background to white – Rachel Gallen Jun 15 '14 at 20:03
-
One cannot simply change the native views. Make custom or use native. – berserk Jun 15 '14 at 20:04
-
I have tried adding `android:background="#ffffff"` and `android:background="@android:color/transparent"` to the progress bar but that doesn't seem to work. – Karan Jit Singh Jun 15 '14 at 20:05
-
try http://forums.xamarin.com/discussion/7808/easy-way-to-change-progressbar-standard-color-scheme-in-mono-for-android – Rachel Gallen Jun 15 '14 at 20:06
-
http://android.okhelp.cz/progressbar-background-and-fore-color-android-sample/ – Rachel Gallen Jun 15 '14 at 20:08
-
@RachelGallen all these links defeat my purpose as they do not give me native look. Is there any way where I can get the native look and get rid of the grey background? – Karan Jit Singh Jun 15 '14 at 20:13
-
are you using holo light? – Rachel Gallen Jun 15 '14 at 20:25
-
1holo-light is different http://android-holo-colors.com/ – Rachel Gallen Jun 15 '14 at 20:36
2 Answers
3
I have already answered a question with a similar requirement:
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"

Antimonit
- 2,846
- 23
- 34
-
1
-
1@MauroAlexandro see https://stackoverflow.com/a/43252422/818821 but I found I had to do `((LayerDrawable) drawable).setDrawableForLayerId(android.R.id.progress, newDrawable)` because the drawable is a layer list – Tim Kist Apr 23 '19 at 16:31
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"

Pedro Romão
- 2,285
- 28
- 22