Java 类android.graphics.drawable.ClipDrawable 实例源码

项目:Nird2    文件:StrengthMeter.java   
public StrengthMeter(Context context, AttributeSet attrs) {
    super(context, attrs, android.R.attr.progressBarStyleHorizontal);
    bar = new ShapeDrawable();
    bar.getPaint().setColor(RED);
    ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
    ShapeDrawable background = new ShapeDrawable();
    Paint p = background.getPaint();
    p.setStyle(FILL);
    p.setColor(getResources().getColor(android.R.color.transparent));
    p.setStyle(STROKE);
    p.setStrokeWidth(1);
    p.setColor(BLACK);
    Drawable[] layers = new Drawable[] { clip, background };
    setProgressDrawable(new LayerDrawable(layers));
    setIndeterminate(false);
}
项目:Nird2    文件:StrengthMeter.java   
public StrengthMeter(Context context, AttributeSet attrs) {
    super(context, attrs, android.R.attr.progressBarStyleHorizontal);
    bar = new ShapeDrawable();
    bar.getPaint().setColor(RED);
    ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
    ShapeDrawable background = new ShapeDrawable();
    Paint p = background.getPaint();
    p.setStyle(FILL);
    p.setColor(getResources().getColor(android.R.color.transparent));
    p.setStyle(STROKE);
    p.setStrokeWidth(1);
    p.setColor(BLACK);
    Drawable[] layers = new Drawable[] { clip, background };
    setProgressDrawable(new LayerDrawable(layers));
    setIndeterminate(false);
}
项目:ArtOfAndroid    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.tv_transition).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
            drawable.startTransition(3000);
        }
    });

    ScaleDrawable scaleDrawable = (ScaleDrawable) findViewById(R.id.v_scale).getBackground();
    scaleDrawable.setLevel(10);      //lever默认为0,无法显示。level范围为0~10000。level越大,显示的越大

    ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.v_clip).getBackground();
    clipDrawable.setLevel(5000);

    View vCustom = findViewById(R.id.v_custom);
    CustomDrawable customDrawable = new CustomDrawable(getResources().getColor(R.color.colorAccent));
    vCustom.setBackground(customDrawable);
}
项目:LoadingImageView    文件:LoadingImageView.java   
private void initMaskBitmap(int maskColor) {
    Drawable drawable = getDrawable();
    if(drawable == null){
        return;
    }
    Bitmap bgd = ((BitmapDrawable) drawable).getBitmap();
    imageWidth = drawable.getIntrinsicWidth();
    imageHeight = drawable.getIntrinsicHeight();

    Bitmap fg = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888);
    Canvas fgCanvas = new Canvas(fg);
    fgCanvas.drawColor(maskColor);


    Bitmap bitmap = combineImages(bgd, fg);
    maskDrawable = new BitmapDrawable(bitmap);
    clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion);

    //shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    //paint.setShader(shader);
}
项目:yelo-android    文件:SwipeClearLayout.java   
private void setTargetOffsetTopAndBottom(int offset) {
    circle.offsetTopAndBottom(offset);
    currentTargetOffsetTop = circle.getTop();
    int percent = (int) ((currentTargetOffsetTop / distanceToTriggerSync) * 100);
    if (onSwipeListener != null) {
        onSwipeListener.onSwipe(percent, currentTargetOffsetTop);
    }
    ViewCompat.setElevation(circle, percent);
    ImageView imageView = (ImageView) circle;
    ClipDrawable clipDrawable = (ClipDrawable) imageView.getDrawable();

    if (percent < 50) {
        clipDrawable.setLevel(0);
    } else {
        clipDrawable.setLevel((percent - 50) * 2 * 100);
    }
}
项目:Loop    文件:LoadingImageView.java   
private void initMaskBitmap(int maskColor) {
    Drawable drawable = getDrawable();
    if(drawable == null){
        return;
    }
    Bitmap bgd = ((BitmapDrawable) drawable).getBitmap();
    imageWidth = drawable.getIntrinsicWidth();
    imageHeight = drawable.getIntrinsicHeight();

    Bitmap fg = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888);
    Canvas fgCanvas = new Canvas(fg);
    fgCanvas.drawColor(maskColor);


    Bitmap bitmap = combineImages(bgd, fg);
    maskDrawable = new BitmapDrawable(bitmap);
    clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion);

    //shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    //paint.setShader(shader);
}
项目:Noyze    文件:CmBatteryBar.java   
/**
 * Updates the {@link ShapeDrawable} which displays the
 * color of the bar across the screen.
 */
public void setProgressDrawable(Drawable mDrawable, int mNewColor)
{
    if (mDrawable instanceof LayerDrawable &&
        getProgressDrawable() instanceof LayerDrawable)
    {
        final LayerDrawable mDraw = (LayerDrawable) getProgressDrawable();
        final ClipDrawable mShape = (ClipDrawable)
            mDraw.findDrawableByLayerId(android.R.id.progress);

        // Make sure we've got everything.
        if (mShape != null && mProgress != null &&
            mProgress.getPaint() != null)
        {
            mProgress.getPaint().setColor(mNewColor);
            final Rect mBounds = mDraw.getBounds();
            super.setProgressDrawable(mDraw);
            getProgressDrawable().setBounds(mBounds);
            return;
        }
    }

    super.setProgressDrawable(mDrawable);
}
项目:365browser    文件:ClipDrawableProgressBar.java   
/**
 * Create the progress bar with a custom height.
 * @param context An Android context.
 * @param height The height in px of the progress bar.
 */
public ClipDrawableProgressBar(Context context, int height) {
    super(context);

    mDesiredVisibility = getVisibility();

    int foregroundColor =
            ApiCompatibilityUtils.getColor(getResources(), R.color.progress_bar_foreground);
    mBackgroundColor =
            ApiCompatibilityUtils.getColor(getResources(), R.color.progress_bar_background);

    mForegroundDrawable = new ColorDrawable(foregroundColor);
    setImageDrawable(
            new ClipDrawable(mForegroundDrawable, Gravity.START, ClipDrawable.HORIZONTAL));
    setBackgroundColor(mBackgroundColor);

    setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height));
}
项目:itsnat_droid    文件:Assert.java   
public static void assertEquals(ClipDrawable a,ClipDrawable b)
{
    assertEqualsDrawableWrapper(a, b);

    Rect ar = new Rect(); Rect br = new Rect();
    a.getPadding(ar); b.getPadding(br);
    assertEquals(ar, br);

    Drawable.ConstantState a_state = a.getConstantState();
    Drawable.ConstantState b_state = b.getConstantState();

    Class classClipState = TestUtil.resolveClass(ClipDrawable.class.getName() + "$ClipState");
    assertEquals((Integer) TestUtil.getField(a_state, classClipState, "mOrientation"), (Integer) TestUtil.getField(b_state, classClipState, "mOrientation"));
    assertEquals((Integer) TestUtil.getField(a_state, classClipState, "mGravity"), (Integer) TestUtil.getField(b_state, classClipState, "mGravity"));

    // android:drawable
    if (Build.VERSION.SDK_INT < TestUtil.MARSHMALLOW) // 23
    {
        assertEquals((Drawable) TestUtil.getField(a_state, classClipState, "mDrawable"), (Drawable) TestUtil.getField(b_state, classClipState, "mDrawable"));
    }
}
项目:android-art-res    文件:MainActivity.java   
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        // test transition
        View v = findViewById(R.id.test_transition);
        TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
        drawable.startTransition(1000);

        // test scale
        View testScale = findViewById(R.id.test_scale);
        ScaleDrawable testScaleDrawable = (ScaleDrawable) testScale.getBackground();
        testScaleDrawable.setLevel(10);

        // test clip
        ImageView testClip = (ImageView) findViewById(R.id.test_clip);
        ClipDrawable testClipDrawable = (ClipDrawable) testClip.getDrawable();
        testClipDrawable.setLevel(8000);

        // test custom drawable
        View testCustomDrawable = findViewById(R.id.test_custom_drawable);
        CustomDrawable customDrawable = new CustomDrawable(Color.parseColor("#0ac39e"));
        testCustomDrawable.setBackgroundDrawable(customDrawable);
    }
}
项目:androidApp    文件:ReportView.java   
private void setShadow(int drawableId) {
    Drawable original = ContextCompat.getDrawable(TranSappApplication.getAppContext(), drawableId) ;
    Drawable shadow = getClone(original).mutate();
    toGrayScale(shadow);

    Drawable background = getClone(original).mutate();
    background.setColorFilter(
            ContextCompat.getColor(getContext(), R.color.background_white), PorterDuff.Mode.SRC_ATOP);

    Drawable drawableArray[]= new Drawable[]{background, shadow};
    LayerDrawable layerDraw = new LayerDrawable(drawableArray);


    clipDrawable = new ClipDrawable(layerDraw, Gravity.BOTTOM, ClipDrawable.VERTICAL);
    this.shadow.setImageDrawable(clipDrawable);
}
项目:pure    文件:AppMaterial.java   
/** RatingBar 星星 */
public static Drawable RATINGBAR_PROGERSS_DRAWABLE() {
    Drawable[] layers = new Drawable[3];
    Drawable darwable1 = getDrawable(IcomoonIcon.ICON_IC_STAR_NORMAL, NUMBER_3_INT,10,10);
    Drawable darwable2 = getDrawable(IcomoonIcon.ICON_IC_STAR_NORMAL, NUMBER_3_INT,10,10);
    Drawable darwable3 = getDrawable(IcomoonIcon.ICON_IC_STAR_SOLID, NUMBER_3_INT,10,10);


    layers[0] = darwable1;
    layers[1] = new ClipDrawable(darwable2, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    layers[2] = new ClipDrawable(darwable3, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    LayerDrawable drawable = new LayerDrawable(layers);
    drawable.setId(0, android.R.id.background);
    drawable.setId(1, android.R.id.secondaryProgress);
    drawable.setId(2, android.R.id.progress);
    return drawable;
}
项目:pure    文件:MaterialUtils.java   
private Drawable buildRatingBarDrawables(Bitmap[] images) {
    final int[] requiredIds = { android.R.id.background, android.R.id.secondaryProgress, android.R.id.progress };
    final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
    Drawable[] pieces = new Drawable[3];
    for (int i = 0; i < 3; i++) {

        ShapeDrawable sd = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));

        BitmapShader bitmapShader = new BitmapShader(images[i], Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        sd.getPaint().setShader(bitmapShader);

        ClipDrawable cd = new ClipDrawable(sd, Gravity.LEFT, ClipDrawable.HORIZONTAL);
        if (i == 0) {
            pieces[i] = sd;
        } else {
            pieces[i] = cd;
        }
    }
    LayerDrawable ld = new LayerDrawable(pieces);
    for (int i = 0; i < 3; i++) {
        ld.setId(i, requiredIds[i]);
    }
    return ld;
}
项目:briar    文件:StrengthMeter.java   
public StrengthMeter(Context context) {
    super(context, null, android.R.attr.progressBarStyleHorizontal);
    bar = new ShapeDrawable();
    bar.getPaint().setColor(RED);
    ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
    ShapeDrawable background = new ShapeDrawable();
    Paint p = background.getPaint();
    p.setStyle(FILL);
    p.setColor(getResources().getColor(android.R.color.transparent));
    p.setStyle(STROKE);
    p.setStrokeWidth(1);
    p.setColor(BLACK);
    Drawable[] layers = new Drawable[] { clip, background };
    setProgressDrawable(new LayerDrawable(layers));
    setIndeterminate(false);
}
项目:Orpheus    文件:ProfilePortraitView.java   
void positionStickyHeader() {
    // sticky header
    final int top = mListHeader.getTop();
    final int stickyHeight = mStickyHeader.getMeasuredHeight();
    final int headerHeight = mListHeader.getMeasuredHeight();
    final int delta = headerHeight - stickyHeight;
    final int pos = delta + top;
    // reposition header
    mStickyHeader.setTranslationY(Math.max(pos,0));
    if (pos < 0 && !mIsStuck) {
        mIsStuck = true;
        makeSlideAnimator(5000, 10000, (ClipDrawable)mStickyHeader.getBackground()).start();
    } else if (pos > 0 && mIsStuck) {
        mIsStuck = false;
        makeSlideAnimator(10000, 5000, (ClipDrawable)mStickyHeader.getBackground()).start();
    }
}
项目:Orpheus    文件:PlaylistPortraitView.java   
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    // logic here derived from http://antoine-merle.com/blog/2013/10/04/making-that-google-plus-profile-screen/
    if (visibleItemCount == 0) return;
    if (firstVisibleItem == 0 && mList.getChildCount() > 0) {
        // parallax
        mHeroContainer.setTranslationY(-mList.getChildAt(0).getTop() / 2);
    }
    // sticky header
    final int top = mListHeader.getTop();
    final int stickyHeight = mStickyHeader.getMeasuredHeight();
    final int headerHeight = mListHeader.getMeasuredHeight();
    final int delta = headerHeight - stickyHeight;
    final int pos = delta + top;
    // reposition header
    mStickyHeader.setTranslationY(Math.max(pos,0));
    if (pos < 0 && !mIsStuck) {
        mIsStuck = true;
        makeSlideAnimator(5000, 10000, (ClipDrawable)mStickyHeader.getBackground()).start();
    } else if (pos > 0 && mIsStuck) {
        mIsStuck = false;
        makeSlideAnimator(10000,5000, (ClipDrawable)mStickyHeader.getBackground()).start();
    }
}
项目:appdeck-android    文件: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)
                        .strokeWidth(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);
    }
}
项目:Noyze    文件:CmBatteryBar.java   
/**
 * Updates the {@link ShapeDrawable} which displays the
 * color of the bar across the screen.
 */
public void setProgressDrawable(Drawable mDrawable, int mNewColor)
{
    if (mDrawable instanceof LayerDrawable &&
        getProgressDrawable() instanceof LayerDrawable)
    {
        final LayerDrawable mDraw = (LayerDrawable) getProgressDrawable();
        final ClipDrawable mShape = (ClipDrawable)
            mDraw.findDrawableByLayerId(android.R.id.progress);

        // Make sure we've got everything.
        if (mShape != null && mProgress != null &&
            mProgress.getPaint() != null)
        {
            mProgress.getPaint().setColor(mNewColor);
            final Rect mBounds = mDraw.getBounds();
            super.setProgressDrawable(mDraw);
            getProgressDrawable().setBounds(mBounds);
            return;
        }
    }

    super.setProgressDrawable(mDrawable);
}
项目:Klyph    文件: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);
    }
}
项目:CodeLessDoMore    文件: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)

                        .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);
    }
}
项目:mpd-control    文件: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)
                        .strokeWidth(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);
    }
}
项目:danmaku-project    文件:SwitchSeekBar.java   
private void init(Context context) {
    setOnSeekBarChangeListener(this);
    scaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mChecked = false;
    progressDrawable = (LayerDrawable) getProgressDrawable();
    outDrawables = new Drawable[progressDrawable.getNumberOfLayers()];
    for (int i = 0; i < progressDrawable.getNumberOfLayers(); i++) {
        switch (progressDrawable.getId(i)) {
        case android.R.id.progress:// ���ý����
            proDrawable = (ClipDrawable) progressDrawable.getDrawable(i);
            break;
        default:
            break;
        }
    }
}
项目:Team11Prototype    文件: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)
                        .strokeWidth(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);
    }
}
项目:mpdroid-2014    文件: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);
    }
}
项目: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);
    }
}
项目:ghostcommander-supath    文件:SelZoneDialog.java   
private final LayerDrawable createSeekBarDrawable( int fg_color ) {
    LayerDrawable ld = null;
    try {
        Drawable[] list = new Drawable[2];
        final int bg_color = 0xff9d9e9d;
        GradientDrawable bg = Utils.getShadingEx( atRight ? fg_color : bg_color, 0.6f );
        bg.setCornerRadius( 5 );
        list[0] = bg;
        GradientDrawable fg = Utils.getShadingEx( atRight ? bg_color : fg_color, 0.6f );
        fg.setCornerRadius( 5 );
        list[1] = new ClipDrawable( fg, Gravity.LEFT, ClipDrawable.HORIZONTAL );
        ld = new LayerDrawable( list );
        ld.setId( 0, android.R.id.background );
        ld.setId( 1, android.R.id.progress );
    }
    catch( Exception e ) {
        e.printStackTrace();
    }
    return ld;
}
项目:SimpleRatingBar    文件:PartialView.java   
public void setFilledDrawable(Drawable drawable) {
    if (drawable.getConstantState() == null) {
        return;
    }

    ClipDrawable clipDrawable = new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.START, ClipDrawable.HORIZONTAL);
    mFilledView.setImageDrawable(clipDrawable);
}
项目:SimpleRatingBar    文件:PartialView.java   
public void setEmptyDrawable(Drawable drawable) {
    if (drawable.getConstantState() == null) {
        return;
    }

    ClipDrawable clipDrawable = new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.END, ClipDrawable.HORIZONTAL);
    mEmptyView.setImageDrawable(clipDrawable);
}
项目:tumbviewer    文件:DownloadFragment.java   
RxDownloadVH(View itemView) {
    super(itemView);
    progressDrawable = (ClipDrawable) itemView.getBackground();
    stateView = (ImageView) itemView.findViewById(R.id.download_state);
    progress = (TextView) itemView.findViewById(R.id.progress);
    urlView = (TextView) itemView.findViewById(R.id.url);
    stateView.setOnClickListener(this);
    itemView.setOnClickListener(this);
}
项目:phonk    文件:PSlider_.java   
public PSlider_(AppRunner appRunner) {
    super(appRunner.getAppContext());
    super.setMax(MAX_VALUE);
    // setProgressDrawable(getResources().getDrawable(R.drawable.ui_seekbar_progress));

    mSlider = this;
    // getStyles = new Styler(appRunner, this);

    //Custom background drawable allows you to draw how you want it to look if needed
    // SeekBarBackgroundDrawable backgroundDrawable = new SeekBarBackgroundDrawable(appRunner.getAppContext());
    ColorDrawable progressDrawable = new ColorDrawable(Color.BLUE);
    SeekBarProgressDrawable clipProgressDrawable = new SeekBarProgressDrawable(progressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL, appRunner.getAppContext());

    ColorDrawable progressDrawable2 = new ColorDrawable(Color.GREEN);
    //Custom seek bar slider drawable. Also allows you to modify appearance.
    InsetDrawable insetDrawable = new InsetDrawable(progressDrawable2, 0, 0, 0, 0);

    Drawable[] drawables = new Drawable[]{ insetDrawable, clipProgressDrawable };

    //Create layer drawables with android pre-defined ids
    LayerDrawable layerDrawable = new LayerDrawable(drawables);
    // layerDrawable.setId(0,android.R.id.background);
    // layerDrawable.setId(1,android.R.id.slider);

    //Set to seek bar
    setThumb(null);
    setProgressDrawable(layerDrawable);
}
项目:libcommon    文件:ProgressView.java   
protected void refreshDrawable(final Drawable drawable) {
    mDrawable = drawable;
    if (mDrawable == null) {
        mDrawable = new ColorDrawable(mColor);
    }
    int gravity = GRAVITY_FILL_VERTICAL | GRAVITY_LEFT;
    int orientation = ClipDrawable.HORIZONTAL;
    switch (mRotation) {
    case 90:
        gravity = GRAVITY_FILL_HORIZONTAL | GRAVITY_BOTTOM;
        orientation = ClipDrawable.VERTICAL;
        break;
    case 180:
        gravity = GRAVITY_FILL_VERTICAL | GRAVITY_RIGHT;
        orientation = ClipDrawable.HORIZONTAL;
        break;
    case 270:
        gravity = GRAVITY_FILL_HORIZONTAL | GRAVITY_TOP;
        orientation = ClipDrawable.VERTICAL;
        break;
    }
    mClipDrawable = new ClipDrawable(mDrawable, gravity, orientation);
    final Rect outRect = new Rect();
    getDrawingRect(outRect);
    mClipDrawable.setBounds(outRect);
    mClipDrawable.setLevel((int)(mProgress * mScale) + mMin);
    postInvalidate();
}
项目:solved-hacking-problem    文件:bb.java   
private Drawable m2538a(Drawable drawable, boolean z) {
    int i = 0;
    Drawable a;
    if (drawable instanceof C0063q) {
        a = ((C0063q) drawable).m469a();
        if (a != null) {
            ((C0063q) drawable).m473a(m2538a(a, z));
        }
    } else if (drawable instanceof LayerDrawable) {
        LayerDrawable layerDrawable = (LayerDrawable) drawable;
        int numberOfLayers = layerDrawable.getNumberOfLayers();
        Drawable[] drawableArr = new Drawable[numberOfLayers];
        for (int i2 = 0; i2 < numberOfLayers; i2++) {
            int id = layerDrawable.getId(i2);
            Drawable drawable2 = layerDrawable.getDrawable(i2);
            boolean z2 = id == 16908301 || id == 16908303;
            drawableArr[i2] = m2538a(drawable2, z2);
        }
        a = new LayerDrawable(drawableArr);
        while (i < numberOfLayers) {
            a.setId(i, layerDrawable.getId(i));
            i++;
        }
        return a;
    } else if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        Bitmap bitmap = bitmapDrawable.getBitmap();
        if (this.f1344d == null) {
            this.f1344d = bitmap;
        }
        Drawable shapeDrawable = new ShapeDrawable(m2539b());
        shapeDrawable.getPaint().setShader(new BitmapShader(bitmap, TileMode.REPEAT, TileMode.CLAMP));
        shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
        return z ? new ClipDrawable(shapeDrawable, 3, 1) : shapeDrawable;
    }
    return drawable;
}
项目:solved-hacking-problem    文件:bb.java   
private Drawable m2538a(Drawable drawable, boolean z) {
    int i = 0;
    Drawable a;
    if (drawable instanceof C0063q) {
        a = ((C0063q) drawable).m469a();
        if (a != null) {
            ((C0063q) drawable).m473a(m2538a(a, z));
        }
    } else if (drawable instanceof LayerDrawable) {
        LayerDrawable layerDrawable = (LayerDrawable) drawable;
        int numberOfLayers = layerDrawable.getNumberOfLayers();
        Drawable[] drawableArr = new Drawable[numberOfLayers];
        for (int i2 = 0; i2 < numberOfLayers; i2++) {
            int id = layerDrawable.getId(i2);
            Drawable drawable2 = layerDrawable.getDrawable(i2);
            boolean z2 = id == 16908301 || id == 16908303;
            drawableArr[i2] = m2538a(drawable2, z2);
        }
        a = new LayerDrawable(drawableArr);
        while (i < numberOfLayers) {
            a.setId(i, layerDrawable.getId(i));
            i++;
        }
        return a;
    } else if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        Bitmap bitmap = bitmapDrawable.getBitmap();
        if (this.f1344d == null) {
            this.f1344d = bitmap;
        }
        Drawable shapeDrawable = new ShapeDrawable(m2539b());
        shapeDrawable.getPaint().setShader(new BitmapShader(bitmap, TileMode.REPEAT, TileMode.CLAMP));
        shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
        return z ? new ClipDrawable(shapeDrawable, 3, 1) : shapeDrawable;
    }
    return drawable;
}
项目:EggProgressSDK    文件:EggLoadingProgress.java   
public void onShowEggLoadingProgressBar(boolean cancelable, int max, int color) {
    mProgress = new ProgressDialog(mContext);
    mProgress.setCancelable(cancelable);
    mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    LayerDrawable layer = (LayerDrawable) ContextCompat.getDrawable(mContext, R.drawable.custom_linear_progress);
    ClipDrawable progress = (ClipDrawable) (layer.findDrawableByLayerId(R.id.progress));
    progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    mProgress.setProgressDrawable(layer);
    mProgress.setProgress(0);
    mProgress.setMax(max);
    mProgress.show();
}
项目:EggProgressSDK    文件:EggLoadingProgress.java   
public void onShowEggLoadingProgressBar(boolean cancelable, int max, int color, String title, String message) {
    mProgress = new ProgressDialog(mContext);
    if(!title.equals("")) mProgress.setTitle(title);
    if(!message.equals("")) mProgress.setMessage(message);
    mProgress.setCancelable(cancelable);
    mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    LayerDrawable layer = (LayerDrawable) ContextCompat.getDrawable(mContext, R.drawable.custom_linear_progress);
    ClipDrawable progress = (ClipDrawable) (layer.findDrawableByLayerId(R.id.progress));
    progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    mProgress.setProgressDrawable(layer);
    mProgress.setProgress(0);
    mProgress.setMax(max);
    mProgress.show();
}
项目:WhiteRead    文件:MMWebView.java   
private void initProgress(Context context) {
    if (mProgressbar == null) {
        mProgressbar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
        mProgressbar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 12, 0, 0));
        mProgressbar.setMax(100);
        mProgressbar.setProgress(0);
        mProgressbar.setBackgroundColor(0xffcccccc);
        ClipDrawable d = new ClipDrawable(new ColorDrawable(mProgressColor), Gravity.START, ClipDrawable.HORIZONTAL);
        mProgressbar.setProgressDrawable(d);
    }

    if (indexOfChild(mProgressbar) == -1) {
        addView(mProgressbar);
    }
}
项目: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();
}
项目: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);
    }
}
项目:BetterRatingBar    文件:BetterRatingBar.java   
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) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        return (clip) ? new ClipDrawable(bitmapDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : bitmapDrawable;
    }

    return drawable;
}
项目:soulissapp    文件:NodeDetailFragment.java   
/**
 * Riga grigia cra spazio
 */
private void createHeader() {

    if (collected.getIconResourceId() != 0)
        FontAwesomeUtil.prepareAwesomeFontAweTextView(getActivity(), nodeic, SimpleTagViewUtils.getAwesomeNames(getActivity()).get(collected.getIconResourceId()));


    par.setMax(Constants.MAX_HEALTH);

    // ProgressBar sfumata
    final ShapeDrawable pgDrawable = new ShapeDrawable(new RoundRectShape(Constants.roundedCorners, null, null));
    final LinearGradient gradient = new LinearGradient(0, 0, 250, 0, getResources().getColor(color.aa_red),
            getResources().getColor(color.aa_green), android.graphics.Shader.TileMode.CLAMP);
    // pgDrawable.getPaint().setStrokeWidth(3);
    pgDrawable.getPaint().setDither(true);
    pgDrawable.getPaint().setShader(gradient);

    ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.START, ClipDrawable.HORIZONTAL);
    par.setBackgroundResource(android.R.drawable.progress_horizontal);
    par.setProgressDrawable(progress);
    par.setMax(50);
    par.setProgress(20);
    par.setProgress(0); // <-- BUG Android
    par.setMax(Constants.MAX_HEALTH);
    refreshHeader();

    Log.d(Constants.TAG,
            "Setting bar at " + collected.getHealth() + " win width=" + SoulissApp.getDisplayWidth() / 2);
}