java类android.graphics.drawable.LayerDrawable的实例源码

BubbleDrawableBuilder.java 文件源码 项目:Cable-Android 阅读 46 收藏 0 点赞 0 评论 0
public Drawable create(Context context) {
  final GradientDrawable bubble = new GradientDrawable();
  final int              radius = context.getResources().getDimensionPixelSize(R.dimen.message_bubble_corner_radius);
  final float[]          radii  = cornerBooleansToRadii(corners, radius);

  bubble.setColor(color);
  bubble.setCornerRadii(radii);

  if (!hasShadow) {
    return bubble;
  } else {
    final GradientDrawable shadow   = new GradientDrawable();
    final int              distance = context.getResources().getDimensionPixelSize(R.dimen.message_bubble_shadow_distance);

    shadow.setColor(shadowColor);
    shadow.setCornerRadii(radii);

    final LayerDrawable layers = new LayerDrawable(new Drawable[]{shadow, bubble});
    layers.setLayerInset(1, 0, 0, 0, distance);
    return layers;
  }
}
FloatingActionButton.java 文件源码 项目:GitHub 阅读 35 收藏 0 点赞 0 评论 0
protected LayerDrawable generateFinalDrawables(RectF circleRect) {
    if (mSize == SIZE_NOSHADOW) {
        return new LayerDrawable(
                new Drawable[]{
                        createFillDrawable(circleRect),
                        createStrokesDrawable(circleRect),
                        getIconDrawable()
                });
    } else {
        return new LayerDrawable(
                new Drawable[]{
                        getResources().getDrawable(getDrawableBySize(mSize)),
                        createFillDrawable(circleRect),
                        createStrokesDrawable(circleRect),
                        getIconDrawable()
                });
    }
}
TintLayerDrawable.java 文件源码 项目:android_ui 阅读 35 收藏 0 点赞 0 评论 0
/**
 * Updates tint of a layer with the specified <var>layerId</var> of the wrapped drawable
 * depends on the specified <var>stateSet</var>.
 *
 * @param layerId  Id of the desired layer of which tint to update.
 * @param stateSet State set to properly resolve tint color.
 * @return {@code True} if tint has ben updated, {@code false} otherwise.
 */
private boolean updateDrawableLayerTint(int layerId, int[] stateSet) {
    if ((mPrivateFlags & PFLAG_HAS_COLOR_FILTER) == 0) {
        final Drawable drawable = ((LayerDrawable) mDrawable).findDrawableByLayerId(layerId);
        if (drawable == null) {
            return false;
        }

        final DrawableLayerTint layerTint = mDrawableLayerTints != null ? mDrawableLayerTints.get(layerId) : null;
        if (layerTint != null && layerTint.tintList != null && layerTint.tintMode != null) {
            final int tintColor = layerTint.tintList.getColorForState(stateSet, layerTint.currentTint);

            if (tintColor != layerTint.currentTint || (mPrivateFlags & PFLAG_TINT_COLOR_CACHING_ENABLED) == 0) {
                drawable.setColorFilter(new PorterDuffColorFilter(tintColor, layerTint.tintMode));
                layerTint.currentTint = tintColor;
            }
        } else {
            drawable.clearColorFilter();
        }
        return true;
    }
    return false;
}
UploadFileActivity.java 文件源码 项目:Rxjava2.0Demo 阅读 37 收藏 0 点赞 0 评论 0
@Override
public void initView() {
    mRefreshLayout = findViewById(R.id.refreshLayout);

    int deta = new Random().nextInt(7 * 24 * 60 * 60 * 1000);
    mClassicsHeader = (ClassicsHeader)mRefreshLayout.getRefreshHeader();
    mClassicsHeader.setLastUpdateTime(new Date(System.currentTimeMillis()-deta));
    mClassicsHeader.setTimeFormat(new SimpleDateFormat("更新于 MM-dd HH:mm", Locale.CHINA));
    mClassicsHeader.setTimeFormat(new DynamicTimeFormat("更新于 %s"));
    mClassicsHeader.setSpinnerStyle(SpinnerStyle.Translate);
    mDrawableProgress = mClassicsHeader.getProgressView().getDrawable();
    if (mDrawableProgress instanceof LayerDrawable) {
        mDrawableProgress = ((LayerDrawable) mDrawableProgress).getDrawable(0);
    }

    if (isFirstEnter) {
        isFirstEnter = false;
        //触发自动刷新
        mRefreshLayout.autoRefresh();
    }
}
AlertView.java 文件源码 项目:mapbox-navigation-android 阅读 43 收藏 0 点赞 0 评论 0
private void initBackground() {
  if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
    int progressColor = ThemeSwitcher.retrieveNavigationViewThemeColor(getContext(),
      R.attr.navigationViewProgress);
    int progressBackgroundColor = ThemeSwitcher.retrieveNavigationViewThemeColor(getContext(),
      R.attr.navigationViewProgressBackground);

    LayerDrawable progressBarDrawable = (LayerDrawable) alertProgressBar.getProgressDrawable();
    // ProgressBar progress color
    Drawable progressBackgroundDrawable = progressBarDrawable.getDrawable(0);
    progressBackgroundDrawable.setColorFilter(progressBackgroundColor, PorterDuff.Mode.SRC_IN);


    // ProgressBar background color
    Drawable progressDrawable = progressBarDrawable.getDrawable(1);
    progressDrawable.setColorFilter(progressColor, PorterDuff.Mode.SRC_IN);

    // Hide the background
    getBackground().setAlpha(0);
  } else {
    setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
  }
}
ReactHorizontalScrollView.java 文件源码 项目:RNLearn_Project1 阅读 48 收藏 0 点赞 0 评论 0
private ReactViewBackgroundDrawable getOrCreateReactViewBackground() {
  if (mReactBackgroundDrawable == null) {
    mReactBackgroundDrawable = new ReactViewBackgroundDrawable();
    Drawable backgroundDrawable = getBackground();
    super.setBackground(null);  // required so that drawable callback is cleared before we add the
    // drawable back as a part of LayerDrawable
    if (backgroundDrawable == null) {
      super.setBackground(mReactBackgroundDrawable);
    } else {
      LayerDrawable layerDrawable =
          new LayerDrawable(new Drawable[]{mReactBackgroundDrawable, backgroundDrawable});
      super.setBackground(layerDrawable);
    }
  }
  return mReactBackgroundDrawable;
}
BubbleDrawableBuilder.java 文件源码 项目:PeSanKita-android 阅读 31 收藏 0 点赞 0 评论 0
public Drawable create(Context context) {
  final GradientDrawable bubble = new GradientDrawable();
  final int              radius = context.getResources().getDimensionPixelSize(R.dimen.message_bubble_corner_radius);
  final float[]          radii  = cornerBooleansToRadii(corners, radius);

  bubble.setColor(color);
  bubble.setCornerRadii(radii);

  if (!hasShadow) {
    return bubble;
  } else {
    final GradientDrawable shadow   = new GradientDrawable();
    final int              distance = context.getResources().getDimensionPixelSize(R.dimen.message_bubble_shadow_distance);

    shadow.setColor(shadowColor);
    shadow.setCornerRadii(radii);

    final LayerDrawable layers = new LayerDrawable(new Drawable[]{shadow, bubble});
    layers.setLayerInset(1, 0, 0, 0, distance);
    return layers;
  }
}
ReactTextView.java 文件源码 项目:RNLearn_Project1 阅读 40 收藏 0 点赞 0 评论 0
private ReactViewBackgroundDrawable getOrCreateReactViewBackground() {
  if (mReactBackgroundDrawable == null) {
    mReactBackgroundDrawable = new ReactViewBackgroundDrawable();
    Drawable backgroundDrawable = getBackground();
    super.setBackground(null);  // required so that drawable callback is cleared before we add the
    // drawable back as a part of LayerDrawable
    if (backgroundDrawable == null) {
      super.setBackground(mReactBackgroundDrawable);
    } else {
      LayerDrawable layerDrawable =
              new LayerDrawable(new Drawable[]{mReactBackgroundDrawable, backgroundDrawable});
      super.setBackground(layerDrawable);
    }
  }
  return mReactBackgroundDrawable;
}
ReactEditText.java 文件源码 项目:RNLearn_Project1 阅读 35 收藏 0 点赞 0 评论 0
private ReactViewBackgroundDrawable getOrCreateReactViewBackground() {
  if (mReactBackgroundDrawable == null) {
    mReactBackgroundDrawable = new ReactViewBackgroundDrawable();
    Drawable backgroundDrawable = getBackground();
    super.setBackground(null);  // required so that drawable callback is cleared before we add the
    // drawable back as a part of LayerDrawable
    if (backgroundDrawable == null) {
      super.setBackground(mReactBackgroundDrawable);
    } else {
      LayerDrawable layerDrawable =
          new LayerDrawable(new Drawable[]{mReactBackgroundDrawable, backgroundDrawable});
      super.setBackground(layerDrawable);
    }
  }
  return mReactBackgroundDrawable;
}
FloatingActionButtonLibrary.java 文件源码 项目:MyCalendar 阅读 27 收藏 0 点赞 0 评论 0
private Drawable createCircleDrawable(int color, float strokeWidth) {
  int alpha = Color.alpha(color);
  int opaqueColor = opaque(color);

  ShapeDrawable fillDrawable = new ShapeDrawable(new OvalShape());

  final Paint paint = fillDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setColor(opaqueColor);

  Drawable[] layers = {
      fillDrawable,
      createInnerStrokesDrawable(opaqueColor, strokeWidth)
  };

  LayerDrawable drawable = alpha == 255 || !mStrokeVisible
      ? new LayerDrawable(layers)
      : new TranslucentLayerDrawable(alpha, layers);

  int halfStrokeWidth = (int) (strokeWidth / 2f);
  drawable.setLayerInset(1, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth);

  return drawable;
}
SeekBarPreference.java 文件源码 项目:Quran 阅读 29 收藏 0 点赞 0 评论 0
private void styleSeekBar() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    final Drawable progressDrawable = mSeekBar.getProgressDrawable();
    if (progressDrawable != null) {
      if (progressDrawable instanceof LayerDrawable) {
        LayerDrawable ld = (LayerDrawable) progressDrawable;
        int layers = ld.getNumberOfLayers();
        for (int i = 0; i < layers; i++) {
          ld.getDrawable(i).mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
        }
      } else {
        progressDrawable.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      final Drawable thumb = mSeekBar.getThumb();
      if (thumb != null) {
        thumb.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }
  }
}
Switch.java 文件源码 项目:XERUNG 阅读 34 收藏 0 点赞 0 评论 0
public void changeBackground() {
    if (iSchecked) {
        if (!isInEditMode()) {
            setBackgroundResource(R.drawable.background_checkbox);
            LayerDrawable layer = (LayerDrawable) getBackground();
            GradientDrawable shape = (GradientDrawable) layer
                    .findDrawableByLayerId(R.id.shape_bacground);
            shape.setColor(backgroundColor);
        }

    } else {
        if (!isInEditMode()) {
            setBackgroundResource(R.drawable.background_switch_ball_uncheck);
        }
    }
}
Button.java 文件源码 项目:XERUNG 阅读 40 收藏 0 点赞 0 评论 0
@Override
public void setBackgroundColor(int color) {
    backgroundColor = color;
    if (isEnabled()) {
        beforeBackground = backgroundColor;
    }
    try {
        LayerDrawable layer = (LayerDrawable) getBackground();
        // 每个按钮的框架都是由drawable中的xml文件制定的,xml文件中都有一个item的id叫:shape_bacground
        GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground);
        /**
         * 给这个图片设置背景色,因为图片的主体是透明的所以可以直接显示背景色
         * 效果就是一个透明但有阴影的框架下有了背景色,这样的方式可以方便的设置不同颜色的按钮,让按钮看起来还是浑然一体
         */
        shape.setColor(backgroundColor);
        /**
         * 当重新设定背景色后,要检查涟漪颜色。如果已经设定了涟漪颜色,那么就用之前的。如果没设定就重新生成
         */
        if (!settedRippleColor) {
            rippleColor = makePressColor(255);
        }
    } catch (Exception ex) {
        // Without bacground
    }
}
Button.java 文件源码 项目:XERUNG 阅读 36 收藏 0 点赞 0 评论 0
@Override
public void setBackgroundColor(int color) {
    backgroundColor = color;
    if (isEnabled()) {
        beforeBackground = backgroundColor;
    }
    try {
        LayerDrawable layer = (LayerDrawable) getBackground();
        // 每个按钮的框架都是由drawable中的xml文件制定的,xml文件中都有一个item的id叫:shape_bacground
        GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground);
        /**
         * 给这个图片设置背景色,因为图片的主体是透明的所以可以直接显示背景色
         * 效果就是一个透明但有阴影的框架下有了背景色,这样的方式可以方便的设置不同颜色的按钮,让按钮看起来还是浑然一体
         */
        shape.setColor(backgroundColor);
        /**
         * 当重新设定背景色后,要检查涟漪颜色。如果已经设定了涟漪颜色,那么就用之前的。如果没设定就重新生成
         */
        if (!settedRippleColor) {
            rippleColor = makePressColor(255);
        }
    } catch (Exception ex) {
        // Without bacground
    }
}
ReactEditText.java 文件源码 项目:RNLearn_Project1 阅读 31 收藏 0 点赞 0 评论 0
private ReactViewBackgroundDrawable getOrCreateReactViewBackground() {
  if (mReactBackgroundDrawable == null) {
    mReactBackgroundDrawable = new ReactViewBackgroundDrawable();
    Drawable backgroundDrawable = getBackground();
    super.setBackground(null);  // required so that drawable callback is cleared before we add the
    // drawable back as a part of LayerDrawable
    if (backgroundDrawable == null) {
      super.setBackground(mReactBackgroundDrawable);
    } else {
      LayerDrawable layerDrawable =
          new LayerDrawable(new Drawable[]{mReactBackgroundDrawable, backgroundDrawable});
      super.setBackground(layerDrawable);
    }
  }
  return mReactBackgroundDrawable;
}
FloatingActionButton.java 文件源码 项目:TestChat 阅读 41 收藏 0 点赞 0 评论 0
private Drawable createCircleDrawable(int color, float strokeWidth) {
        int alpha = Color.alpha(color);
        int opaqueColor = opaque(color);

        ShapeDrawable fillDrawable = new ShapeDrawable(new OvalShape());

        final Paint paint = fillDrawable.getPaint();
        paint.setAntiAlias(true);
        paint.setColor(opaqueColor);

        Drawable[] layers = {
                fillDrawable,
                createInnerStrokesDrawable(opaqueColor, strokeWidth)
        };

        LayerDrawable drawable = alpha == 255 || !mStrokeVisible
                ? new LayerDrawable(layers)
                : new TranslucentLayerDrawable(alpha, layers);

        int halfStrokeWidth = (int) (strokeWidth / 2f);
        drawable.setLayerInset(1, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth);

        return drawable;
}
QMUIDrawableHelper.java 文件源码 项目:qmui 阅读 37 收藏 0 点赞 0 评论 0
/**
 * 动态创建带上分隔线或下分隔线的Drawable
 *
 * @param separatorColor
 * @param bgColor
 * @param top
 * @return
 */
public static LayerDrawable createItemSeparatorBg(@ColorInt int separatorColor, @ColorInt int bgColor, int separatorHeight, boolean top) {

    ShapeDrawable separator = new ShapeDrawable();
    separator.getPaint().setStyle(Paint.Style.FILL);
    separator.getPaint().setColor(separatorColor);

    ShapeDrawable bg = new ShapeDrawable();
    bg.getPaint().setStyle(Paint.Style.FILL);
    bg.getPaint().setColor(bgColor);

    Drawable[] layers = {separator, bg};
    LayerDrawable layerDrawable = new LayerDrawable(layers);

    layerDrawable.setLayerInset(1, 0, top ? separatorHeight : 0, 0, top ? 0 : separatorHeight);
    return layerDrawable;
}
StrengthMeter.java 文件源码 项目:Nird2 阅读 32 收藏 0 点赞 0 评论 0
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);
}
StrengthMeter.java 文件源码 项目:Nird2 阅读 40 收藏 0 点赞 0 评论 0
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);
}
ReactTextView.java 文件源码 项目:RNLearn_Project1 阅读 39 收藏 0 点赞 0 评论 0
private ReactViewBackgroundDrawable getOrCreateReactViewBackground() {
  if (mReactBackgroundDrawable == null) {
    mReactBackgroundDrawable = new ReactViewBackgroundDrawable();
    Drawable backgroundDrawable = getBackground();
    super.setBackground(null);  // required so that drawable callback is cleared before we add the
    // drawable back as a part of LayerDrawable
    if (backgroundDrawable == null) {
      super.setBackground(mReactBackgroundDrawable);
    } else {
      LayerDrawable layerDrawable =
              new LayerDrawable(new Drawable[]{mReactBackgroundDrawable, backgroundDrawable});
      super.setBackground(layerDrawable);
    }
  }
  return mReactBackgroundDrawable;
}
WXViewUtils.java 文件源码 项目:weex-3d-map 阅读 48 收藏 0 点赞 0 评论 0
public static @Nullable
BorderDrawable getBorderDrawable(@NonNull View view){
  Drawable drawable=view.getBackground();
  if(drawable instanceof BorderDrawable){
    return (BorderDrawable) drawable;
  }
  else if(drawable instanceof LayerDrawable){
    if(((LayerDrawable) drawable).getNumberOfLayers()>1) {
      Drawable innerDrawable=((LayerDrawable) drawable).getDrawable(0);
      if(innerDrawable instanceof BorderDrawable){
        return (BorderDrawable) innerDrawable;
      }
    }
  }
  return null;
}
WXViewUtils.java 文件源码 项目:ucar-weex-core 阅读 32 收藏 0 点赞 0 评论 0
public static @Nullable
BorderDrawable getBorderDrawable(@NonNull View view){
  Drawable drawable=view.getBackground();
  if(drawable instanceof BorderDrawable){
    return (BorderDrawable) drawable;
  }
  else if(drawable instanceof LayerDrawable){
    if(((LayerDrawable) drawable).getNumberOfLayers()>1) {
      Drawable innerDrawable=((LayerDrawable) drawable).getDrawable(0);
      if(innerDrawable instanceof BorderDrawable){
        return (BorderDrawable) innerDrawable;
      }
    }
  }
  return null;
}
OrderDialogFragment.java 文件源码 项目:Mix 阅读 34 收藏 0 点赞 0 评论 0
private Drawable createProductImageDrawable(Product product) {
    final ShapeDrawable background = new ShapeDrawable();
    background.setShape(new OvalShape());
    background.getPaint().setColor(ContextCompat.getColor(getContext(), product.color));

    final BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
            BitmapFactory.decodeResource(getResources(), product.image));

    final LayerDrawable layerDrawable = new LayerDrawable
            (new Drawable[]{background, bitmapDrawable});

    final int padding = (int) getResources().getDimension(R.dimen.spacing_huge);
    layerDrawable.setLayerInset(1, padding, padding, padding, padding);

    return layerDrawable;
}
ThemeUtils.java 文件源码 项目:Mix 阅读 36 收藏 0 点赞 0 评论 0
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't getBaseApplication containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
SelectableRoundedImageView.java 文件源码 项目:BBSSDK-for-Android 阅读 35 收藏 0 点赞 0 评论 0
public static Drawable fromDrawable(Drawable drawable, Resources r) {
    if (drawable != null) {
        if (drawable instanceof SelectableRoundedCornerDrawable) {
            return drawable;
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            final int num = ld.getNumberOfLayers();
            for (int i = 0; i < num; i++) {
                Drawable d = ld.getDrawable(i);
                ld.setDrawableByLayerId(ld.getId(i), fromDrawable(d, r));
            }
            return ld;
        }

        Bitmap bm = drawableToBitmap(drawable);
        if (bm != null) {
            return new SelectableRoundedCornerDrawable(bm, r);
        } else {
        }
    }
    return drawable;
}
RoundedImageView.java 文件源码 项目:AvatarView 阅读 43 收藏 0 点赞 0 评论 0
private void updateAttrs(Drawable drawable) {
    if (drawable == null) {
        return;
    }

    if (drawable instanceof RoundedDrawable) {
        ((RoundedDrawable) drawable).setScaleType(mScaleType).setCornerRadius(cornerRadius)
                .setBorderWidth(borderWidth).setBorderColor(borderColor).setOval(isOval);
    } else if (drawable instanceof LayerDrawable) {
        // loop through layers to and set drawable attrs
        LayerDrawable ld = ((LayerDrawable) drawable);
        for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++) {
            updateAttrs(ld.getDrawable(i));
        }
    }
}
RoundedPagerDrawable.java 文件源码 项目:letv 阅读 32 收藏 0 点赞 0 评论 0
public static Drawable fromDrawable(Drawable drawable) {
    if (drawable == null || (drawable instanceof RoundedPagerDrawable)) {
        return drawable;
    }
    if (drawable instanceof LayerDrawable) {
        Drawable ld = (LayerDrawable) drawable;
        int num = ld.getNumberOfLayers();
        for (int i = 0; i < num; i++) {
            ld.setDrawableByLayerId(ld.getId(i), fromDrawable(ld.getDrawable(i)));
        }
        return ld;
    }
    Bitmap bm = drawableToBitmap(drawable);
    if (bm != null) {
        return new RoundedPagerDrawable(bm);
    }
    return drawable;
}
RoundedImageView.java 文件源码 项目:letv 阅读 38 收藏 0 点赞 0 评论 0
private void updateAttrs(Drawable drawable) {
    if (drawable != null) {
        if (drawable instanceof RoundedPagerDrawable) {
            ((RoundedPagerDrawable) drawable).setScaleType(this.mScaleType).setBorderWidth(this.mBorderWidth).setBorderColor(this.mBorderColor).setOval(this.mIsOval).setTileModeX(this.mTileModeX).setTileModeY(this.mTileModeY);
            if (this.mCornerRadii != null) {
                ((RoundedPagerDrawable) drawable).setCornerRadius(this.mCornerRadii[0], this.mCornerRadii[1], this.mCornerRadii[2], this.mCornerRadii[3]);
            }
            applyColorMod();
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            int layers = ld.getNumberOfLayers();
            for (int i = 0; i < layers; i++) {
                updateAttrs(ld.getDrawable(i));
            }
        }
    }
}
InstaTag.java 文件源码 项目:InstaTag 阅读 40 收藏 0 点赞 0 评论 0
private void setColor(Drawable drawable, int color) {
    if (drawable instanceof ShapeDrawable) {
        ((ShapeDrawable) drawable).getPaint().setColor(color);
    } else if (drawable instanceof GradientDrawable) {
        ((GradientDrawable) drawable).setColor(color);
    } else if (drawable instanceof ColorDrawable) {
        ((ColorDrawable) drawable).setColor(color);
    } else if (drawable instanceof LayerDrawable) {
        LayerDrawable layerDrawable = (LayerDrawable) drawable;
        RotateDrawable rotateDrawable =
                (RotateDrawable) layerDrawable.findDrawableByLayerId(R.id.carrot_shape_top);
        setColor(rotateDrawable.getDrawable(), color);
    } else if (drawable instanceof RotateDrawable) {
        setColor(((RotateDrawable) drawable).getDrawable(), color);
    }
}
RateUsDialog.java 文件源码 项目:android-mvp-interactor-architecture 阅读 34 收藏 0 点赞 0 评论 0
@Override
protected void setUp(View view) {

    mRatingMessageView.setVisibility(View.GONE);
    mPlayStoreRatingView.setVisibility(View.GONE);

    LayerDrawable stars = (LayerDrawable) mRatingBar.getProgressDrawable();
    stars.getDrawable(2)
            .setColorFilter(ContextCompat.getColor(getContext(), R.color.yellow), PorterDuff.Mode.SRC_ATOP);
    stars.getDrawable(0)
            .setColorFilter(ContextCompat.getColor(getContext(), R.color.shadow), PorterDuff.Mode.SRC_ATOP);
    stars.getDrawable(1)
            .setColorFilter(ContextCompat.getColor(getContext(), R.color.shadow), PorterDuff.Mode.SRC_ATOP);

    mSubmitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mPresenter.onRatingSubmitted(mRatingBar.getRating(), mMessage.getText().toString());
        }
    });

}


问题


面经


文章

微信
公众号

扫码关注公众号