android.graphics.drawable.ClipDrawable#HORIZONTAL源码实例Demo

下面列出了android.graphics.drawable.ClipDrawable#HORIZONTAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: KlyphMessenger   文件: DefaultHeaderTransformer.java
private void applyProgressBarSettings() {
    if (mHeaderProgressBar != null) {
        final int strokeWidth = mHeaderProgressBar.getResources()
                .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width);

        mHeaderProgressBar.setIndeterminateDrawable(
                new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext())
                        .color(mProgressDrawableColor)
                        .width(strokeWidth)
                        .build());

        ShapeDrawable shape = new ShapeDrawable();
        shape.setShape(new RectShape());
        shape.getPaint().setColor(mProgressDrawableColor);
        ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);

        mHeaderProgressBar.setProgressDrawable(clipDrawable);
    }
}
 
源代码2 项目: proteus   文件: FixedRatingBar.java
/**
 * Taken from AOSP !!
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
public Drawable getTiledDrawable(Drawable drawable, boolean clip) {

  if (drawable instanceof LayerDrawable) {
    LayerDrawable background = (LayerDrawable) drawable;
    final int N = background.getNumberOfLayers();
    Drawable[] outDrawables = new Drawable[N];

    for (int i = 0; i < N; i++) {
      int id = background.getId(i);
      outDrawables[i] = getTiledDrawable(background.getDrawable(i),
        (id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }

    LayerDrawable newBg = new LayerDrawable(outDrawables);

    for (int i = 0; i < N; i++) {
      newBg.setId(i, background.getId(i));
    }

    return newBg;

  } else if (drawable instanceof BitmapDrawable) {

    final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
    if (sampleTile == null) {
      sampleTile = tileBitmap;
    }
    final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());

    final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
      Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);

    return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
      ClipDrawable.HORIZONTAL) : shapeDrawable;
  }

  return drawable;
}
 
源代码3 项目: Bitocle   文件: DefaultHeaderTransformer.java
private void applyProgressBarSettings() {
    if (mHeaderProgressBar != null) {
        ShapeDrawable shape = new ShapeDrawable();
        shape.setShape(new RectShape());
        shape.getPaint().setColor(mProgressDrawableColor);
        ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);

        mHeaderProgressBar.setProgressDrawable(clipDrawable);
    }
}
 
源代码4 项目: Bitocle   文件: DefaultHeaderTransformer.java
private void applyProgressBarSettings() {
    if (mHeaderProgressBar != null) {
        ShapeDrawable shape = new ShapeDrawable();
        shape.setShape(new RectShape());
        shape.getPaint().setColor(mProgressDrawableColor);
        ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);

        mHeaderProgressBar.setProgressDrawable(clipDrawable);
    }
}
 
源代码5 项目: Man-Man   文件: ProgressBarWrapper.java
private ProgressBar createProgressBar() {
    ProgressBar pb = (ProgressBar) View.inflate(mActivity, R.layout.actionbar_progressbar, null);
    ShapeDrawable shape = new ShapeDrawable();
    shape.setShape(new RectShape());
    shape.getPaint().setColor(Color.parseColor("#FF33B5E5"));
    ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);
    pb.setProgressDrawable(clipDrawable);
    return pb;
}
 
源代码6 项目: AccountBook   文件: ZProgressBar.java
private void createDrawable(){
    Drawable[] layers = new Drawable[2];
    Drawable background = makeBackground();
    Drawable progress = makeProgress();
    ClipDrawable clip = new ClipDrawable(progress
            , Gravity.LEFT, ClipDrawable.HORIZONTAL);
    layers[0] = background;
    layers[1] = clip;
    LayerDrawable layer = new LayerDrawable(layers);
    layer.setId(0, android.R.id.background);
    layer.setId(1, android.R.id.progress);
    setProgressDrawable(layer);
}
 
源代码7 项目: RefreshNow   文件: RefreshNowProgressIndicator.java
public IndicatorConfig build() {
	final LineDrawable line = new LineDrawable();
	line.setColor(progressColor);
	line.setStrokeWidth(progressStrokeWidth);
	final ClipDrawable progressDrawable = new ClipDrawable(line, Gravity.CENTER_VERTICAL,
			ClipDrawable.HORIZONTAL);
	return new IndicatorConfig(changeProgressDrawable ? progressDrawable : null,
			changeIndeterminateDrawable ? indeterminateDrawableBuilder.build() : null);
}
 
源代码8 项目: LoadingImageView   文件: LoadingImageView.java
/**
 * 设置方向
 * @param orientation {@link MaskOrientation}
 */
public void setMaskOrientation(int orientation){
    switch (orientation){
        case MaskOrientation.LeftToRight:
            gravity = Gravity.LEFT;
            orientaion = ClipDrawable.HORIZONTAL;
            break;
        case MaskOrientation.RightToLeft:
            gravity = Gravity.RIGHT;
            orientaion = ClipDrawable.HORIZONTAL;
            break;
        case MaskOrientation.TopToBottom:
            gravity = Gravity.TOP;
            orientaion = ClipDrawable.VERTICAL;
            break;
        case MaskOrientation.BottomToTop:
        default:
            gravity = Gravity.BOTTOM;
            orientaion = ClipDrawable.VERTICAL;
            break;
    }
    if(maskDrawable == null){
        return;
    }
    clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion);
    initAnim();
}
 
源代码9 项目: Kore   文件: RatingBar.java
private FrameLayout createStar(Context context, AttributeSet attrs, int defStyle) {
    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));

    AppCompatImageView ivStarBackground = new AppCompatImageView(context, attrs, defStyle);
    ivStarBackground.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    ivStarBackground.setImageResource(iconResourceId);
    ivStarBackground.setAdjustViewBounds(true);
    ImageViewCompat.setImageTintList(ivStarBackground, ColorStateList.valueOf(backgroundColor));
    frameLayout.addView(ivStarBackground);

    ClipDrawable clipDrawable = new ClipDrawable(
            ContextCompat.getDrawable(context, iconResourceId),
            Gravity.START,
            ClipDrawable.HORIZONTAL);

    AppCompatImageView ivStarForeground = new AppCompatImageView(context, attrs, defStyle);
    ivStarForeground.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    ivStarForeground.setImageDrawable(clipDrawable);
    ivStarForeground.setAdjustViewBounds(true);
    ImageViewCompat.setImageTintList(ivStarForeground, ColorStateList.valueOf(foregroundColor));
    frameLayout.addView(ivStarForeground);

    clipDrawables.add((ClipDrawable) ivStarForeground.getDrawable());

    return frameLayout;
}
 
源代码10 项目: AndroidPullMenu   文件: DefaultHeaderTransformer.java
private void applyProgressBarSettings() {
    if (mHeaderProgressBar != null) {
        ShapeDrawable shape = new ShapeDrawable();
        shape.setShape(new RectShape());
        shape.getPaint().setColor(mProgressDrawableColor);
        ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);

        mHeaderProgressBar.setProgressDrawable(clipDrawable);
    }
}
 
源代码11 项目: proteus   文件: ProgressBarParser.java
Drawable getLayerDrawable(int progress, int background) {
  ShapeDrawable shape = new ShapeDrawable();
  shape.getPaint().setStyle(Paint.Style.FILL);
  shape.getPaint().setColor(background);

  ShapeDrawable shapeD = new ShapeDrawable();
  shapeD.getPaint().setStyle(Paint.Style.FILL);
  shapeD.getPaint().setColor(progress);
  ClipDrawable clipDrawable = new ClipDrawable(shapeD, Gravity.LEFT, ClipDrawable.HORIZONTAL);

  return new LayerDrawable(new Drawable[]{shape, clipDrawable});
}
 
源代码12 项目: SSForms   文件: PartialView.java
public void setFilledDrawable(Drawable drawable) {
    @SuppressLint("RtlHardcoded") ClipDrawable clipDrawable = new ClipDrawable(drawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    mFilledView.setImageDrawable(clipDrawable);
}
 
源代码13 项目: CSipSimple   文件: IcsProgressBar.java
/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable, boolean clip) {

    if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }

        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    }/* else if (drawable instanceof StateListDrawable) {
        StateListDrawable in = (StateListDrawable) drawable;
        StateListDrawable out = new StateListDrawable();
        int numStates = in.getStateCount();
        for (int i = 0; i < numStates; i++) {
            out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
        }
        return out;

    }*/ else if (drawable instanceof BitmapDrawable) {
        final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());

        final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
                Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);

        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}
 
/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable, boolean clip) {
    if (drawable instanceof DrawableWrapper) {
        Drawable inner = ((DrawableWrapper) drawable).getWrappedDrawable();
        if (inner != null) {
            inner = tileify(inner, clip);
            ((DrawableWrapper) drawable).setWrappedDrawable(inner);
        }
    } else if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }
        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    } else if (drawable instanceof BitmapDrawable) {
        final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        final Bitmap tileBitmap = bitmapDrawable.getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
        final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
                Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);
        shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}
 
源代码15 项目: MNProgressHUD   文件: MProgressBarDialog.java
private void configView() {
    try {
        //设置动画
        if (mBuilder != null && mBuilder.animationID != 0 && mDialog.getWindow() != null) {
            mDialog.getWindow().setWindowAnimations(mBuilder.animationID);
        }
    } catch (Exception e) {

    }
    dialog_window_background.setBackgroundColor(mBuilder.backgroundWindowColor);
    tvShow.setTextColor(mBuilder.textColor);

    GradientDrawable myGrad = (GradientDrawable) dialog_view_bg.getBackground();
    myGrad.setColor(mBuilder.backgroundViewColor);
    myGrad.setStroke(MSizeUtils.dp2px(mContext, mBuilder.strokeWidth), mBuilder.strokeColor);
    myGrad.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.cornerRadius));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        dialog_view_bg.setBackground(myGrad);
    } else {
        dialog_view_bg.setBackgroundDrawable(myGrad);
    }

    //horizontalProgressBar 配置
    //背景
    GradientDrawable progressBarBackgroundDrawable = new GradientDrawable();
    progressBarBackgroundDrawable.setColor(mBuilder.progressbarBackgroundColor);
    progressBarBackgroundDrawable.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.progressCornerRadius));
    //二级进度条
    GradientDrawable secondProgressDrawable = new GradientDrawable();
    secondProgressDrawable.setColor(mBuilder.progressbarBackgroundColor);
    secondProgressDrawable.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.progressCornerRadius));
    ClipDrawable hProgressBar02 = new ClipDrawable(secondProgressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    //一级进度条
    GradientDrawable progressDrawable = new GradientDrawable();
    progressDrawable.setColor(mBuilder.progressColor);
    progressDrawable.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.progressCornerRadius));
    ClipDrawable hProgressBar03 = new ClipDrawable(progressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    //组合
    Drawable[] layers = {progressBarBackgroundDrawable, hProgressBar02, hProgressBar03};
    LayerDrawable layerDrawable = new LayerDrawable(layers);
    layerDrawable.setId(0, android.R.id.background);
    layerDrawable.setId(1, android.R.id.secondaryProgress);
    layerDrawable.setId(2, android.R.id.progress);
    horizontalProgressBar.setProgressDrawable(layerDrawable);

    ViewGroup.LayoutParams layoutParams = horizontalProgressBar.getLayoutParams();
    layoutParams.height = MSizeUtils.dp2px(mContext, mBuilder.horizontalProgressBarHeight);
    horizontalProgressBar.setLayoutParams(layoutParams);

    //circularProgressBar 配置
    circularProgressBar.setBackgroundColor(mBuilder.progressbarBackgroundColor);
    circularProgressBar.setColor(mBuilder.progressColor);
    circularProgressBar.setProgressBarWidth(MSizeUtils.dp2px(mContext, mBuilder.circleProgressBarWidth));
    circularProgressBar.setBackgroundProgressBarWidth(MSizeUtils.dp2px(mContext, mBuilder.circleProgressBarBackgroundWidth));
}
 
/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable, boolean clip) {
    if (drawable instanceof DrawableWrapper) {
        Drawable inner = ((DrawableWrapper) drawable).getWrappedDrawable();
        if (inner != null) {
            inner = tileify(inner, clip);
            ((DrawableWrapper) drawable).setWrappedDrawable(inner);
        }
    } else if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }
        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    } else if (drawable instanceof BitmapDrawable) {
        final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        final Bitmap tileBitmap = bitmapDrawable.getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
        final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
                Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);
        shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}
 
源代码17 项目: zen4android   文件: IcsProgressBar.java
/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable, boolean clip) {

    if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }

        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    }/* else if (drawable instanceof StateListDrawable) {
        StateListDrawable in = (StateListDrawable) drawable;
        StateListDrawable out = new StateListDrawable();
        int numStates = in.getStateCount();
        for (int i = 0; i < numStates; i++) {
            out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
        }
        return out;

    }*/ else if (drawable instanceof BitmapDrawable) {
        final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());

        final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
                Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);

        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}
 
/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable, boolean clip) {

    if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }

        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    }/* else if (drawable instanceof StateListDrawable) {
        StateListDrawable in = (StateListDrawable) drawable;
        StateListDrawable out = new StateListDrawable();
        int numStates = in.getStateCount();
        for (int i = 0; i < numStates; i++) {
            out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
        }
        return out;

    }*/ else if (drawable instanceof BitmapDrawable) {
        final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());

        final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
                Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);

        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}
 
public void setProgressColor(ViewHolder vh, int color) {
    Drawable drawable = new ClipDrawable(new ColorDrawable(color),
            Gravity.LEFT, ClipDrawable.HORIZONTAL);
    ((LayerDrawable) vh.mProgressBar.getProgressDrawable())
            .setDrawableByLayerId(android.R.id.progress, drawable);
}
 
源代码20 项目: GreenDamFileExploere   文件: FlatSeekBar.java
private void init(AttributeSet attrs) {

		if (attributes == null)
			attributes = new Attributes(this, getResources());

		if (attrs != null) {
			TypedArray a = getContext().obtainStyledAttributes(attrs,
					R.styleable.fl_FlatSeekBar);

			// getting common attributes
			int customTheme = a.getResourceId(
					R.styleable.fl_FlatSeekBar_fl_theme,
					Attributes.DEFAULT_THEME);
			attributes.setThemeSilent(customTheme, getResources());

			attributes.setSize(a.getDimensionPixelSize(
					R.styleable.fl_FlatSeekBar_fl_size,
					Attributes.DEFAULT_SIZE_PX));

			a.recycle();
		}

		// setting thumb
		PaintDrawable thumb = new PaintDrawable(attributes.getColor(0));
		thumb.setCornerRadius(attributes.getSize() * 9 / 8);
		thumb.setIntrinsicWidth(attributes.getSize() * 9 / 4);
		thumb.setIntrinsicHeight(attributes.getSize() * 9 / 4);
		setThumb(thumb);

		// progress
		PaintDrawable progress = new PaintDrawable(attributes.getColor(1));
		progress.setCornerRadius(attributes.getSize());
		progress.setIntrinsicHeight(attributes.getSize());
		progress.setIntrinsicWidth(attributes.getSize());
		progress.setDither(true);
		ClipDrawable progressClip = new ClipDrawable(progress, Gravity.LEFT,
				ClipDrawable.HORIZONTAL);

		// secondary progress
		PaintDrawable secondary = new PaintDrawable(attributes.getColor(2));
		secondary.setCornerRadius(attributes.getSize());
		secondary.setIntrinsicHeight(attributes.getSize());
		ClipDrawable secondaryProgressClip = new ClipDrawable(secondary,
				Gravity.LEFT, ClipDrawable.HORIZONTAL);

		// background
		PaintDrawable background = new PaintDrawable(attributes.getColor(3));
		background.setCornerRadius(attributes.getSize());
		background.setIntrinsicHeight(attributes.getSize());

		// applying drawable
		LayerDrawable ld = (LayerDrawable) getProgressDrawable();
		ld.setDrawableByLayerId(android.R.id.background, background);
		ld.setDrawableByLayerId(android.R.id.progress, progressClip);
		ld.setDrawableByLayerId(android.R.id.secondaryProgress,
				secondaryProgressClip);
	}
 
 同类方法