I have this code
pb = (ProgressBar) findViewById(R.id.progressBar1);
final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
ShapeDrawable pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
String MyColor = "#00FF00";
pgDrawable.getPaint().setColor(Color.parseColor(MyColor));
ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
pb.setProgressDrawable(progress);
pb.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
The problem in this code is that for the progress drawable and for the secondary progress drawable I have the same color.
How to set the socondary progress color ?
I have also faced the same issue. I add some extra points to the above answer. The seekbar or progressbar is drawn in three layers. First layer is background layer, above that secondary progress layer, above that primary progress.
you can set your custom color to progressbar like this
or like Ridcully said in above answer
It happens that some android os versions do not use the background color of secondary progress. I have checked on android 4.1.2 samsung 8 inch tablet. It doesnot work. In that scenario use background to set your custom color for the secondary progress by setting background, secondary progress color
Specify a
progressDrawable
like in the example below:This goes to a layout:
This goes to
drawable/progressbar.xml
, and here you can specify background and colors for both progress bars.