0

I'm struggling with a kind of feedback given progress bar.

I have an app that controls a measurement device that gives back signal data as numbers and on a run there is tens of signals. In the app I have a progress dialog that shows the progress of a run and the signals as plain text. I'd like to add a kind of a progress bar that would have increment steps with different colors depending of the signal. For example the higher the signal the redder the increment step.

Is it possible to use progress dialog/bar to do that?

Solved by creating a progress bar of my own from blank LinearLayout

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
for(int k=0; k<bar+1; k++) {
    View v = new View(this);
    v.setBackgroundColor(Color.GRAY);
    params.weight = 1;
    v.setLayoutParams(params);
    progress_bar.addView(v, k);
}

Which can then be updated with

progress_bar.getChildAt(check).setBackgroundColor(Color.rgb(r,g,b));

where check is first 0 and is increased by 1 every time

ater
  • 24
  • 3

1 Answers1

0

You could try this:

pBar.getIndeterminateDrawable().setColorFilter(0xFFFF0000,PorterDuff.Mode.Multiply);  

You can also try:

pBar.getProgressDrawable().setColorFilter(0xFFFF0000,PorterDuff.Mode.Multiply); 

Source: Change progressbar color through CODE ONLY in Android

Community
  • 1
  • 1
An SO User
  • 24,612
  • 35
  • 133
  • 221