2

I am trying to use a custom progress bar however it is stuck in indeterminate mode even when I set it to false, and the progressbar is a square. When I supply the width and height for the layoutparams, the width of the bar does not match the width I set, instead it matches the height, making the progressbar a square.

Here is the code:

    ProgressBar pbRightExtruder = new ProgressBar(this);
    LinearLayout.LayoutParams lpProgressBar = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lpProgressBar.weight = 1;
    pbRightExtruder.setLayoutParams(lpProgressBar);
    pbRightExtruder.setProgress(50);
    pbRightExtruder.setIndeterminate(false);
    pbRightExtruder.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progressbar));
    pbRightExtruder.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
    layoutRightExtruder.addView(pbRightExtruder);

What am I missing?

user4232
  • 592
  • 1
  • 12
  • 37

1 Answers1

0

if you are useing weight then set width to 0 instead of LinearLayout.LayoutParams.MATCH_PARENT. Then the weight will work properlly. For indeterminate problem see this.

Community
  • 1
  • 1
maddy d
  • 1,530
  • 2
  • 12
  • 23