Android Open Source - SmoothProgressBar Colors Shape






From Project

Back to project page SmoothProgressBar.

License

The source code is released under:

Apache License

If you think the Android project SmoothProgressBar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.castorflex.android.smoothprogressbar;
/*from w w  w  . jav a 2s  .c  o  m*/
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.shapes.Shape;

/**
 * Created by castorflex on 3/5/14.
 */
public class ColorsShape extends Shape {

  private float mStrokeWidth;
  private int[] mColors;

  public ColorsShape(float strokeWidth, int[] colors) {
    mStrokeWidth = strokeWidth;
    mColors = colors;
  }

  public float getStrokeWidth() {
    return mStrokeWidth;
  }

  public void setStrokeWidth(float strokeWidth) {
    mStrokeWidth = strokeWidth;
  }

  public int[] getColors() {
    return mColors;
  }

  public void setColors(int[] colors) {
    mColors = colors;
  }

  @Override
  public void draw(Canvas canvas, Paint paint) {
    float ratio = 1f / mColors.length;
    int i = 0;
    paint.setStrokeWidth(mStrokeWidth);
    for (int color : mColors) {
      paint.setColor(color);
      canvas.drawLine(i * ratio * getWidth(), getHeight() / 2, ++i * ratio * getWidth(), getHeight() / 2, paint);
    }
  }
}




Java Source Code List

fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.java
fr.castorflex.android.circularprogressbar.CircularProgressBar.java
fr.castorflex.android.circularprogressbar.CircularProgressDrawable.java
fr.castorflex.android.smoothprogressbar.ColorsShape.java
fr.castorflex.android.smoothprogressbar.ContentLoadingSmoothProgressBar.java
fr.castorflex.android.smoothprogressbar.SmoothProgressBarUtils.java
fr.castorflex.android.smoothprogressbar.SmoothProgressBar.java
fr.castorflex.android.smoothprogressbar.SmoothProgressDrawable.java
fr.castorflex.android.smoothprogressbar.sample.MainActivity.java
fr.castorflex.android.smoothprogressbar.sample.MakeCustomActivity.java