List of usage examples for android.widget ProgressBar getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:com.restswitch.controlpanel.MainActivity.java
public void setProgressBars(String pb1Text, int pb1Pos, String pb2Text, int pb2Pos) { ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar); pb.setProgress(pb1Pos);/*from w w w. j a va2 s . c o m*/ pb.setSecondaryProgress(pb2Pos); TextView tv1 = (TextView) findViewById(R.id.progressBarText); tv1.setText(pb1Text); TextView tv2 = (TextView) findViewById(R.id.secondaryProgressBarText); tv2.setText(pb2Text); int pbwTot = pb.getWidth(); int pbw1 = ((pbwTot * pb1Pos) / 100); tv1.setWidth(pbw1); pbw1 += 96; int pbw2 = (pbwTot - pbw1); ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) tv2.getLayoutParams(); mlp.setMargins(pbw1, 2, 0, 0); tv2.setWidth(pbw2); }