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

项目:GitHub    文件:DrawableHelper.java   
/**被按下时的背景*/
public static Drawable createCornerBgPressed(Context c) {
    SizeHelper.prepare(c);

    // prepare
    int strokeWidth = SizeHelper.fromPxWidth(1);
    int roundRadius = SizeHelper.fromPxWidth(6);
    int strokeColor = Color.parseColor("#ffc9c9cb");
    int fillColor = Color.parseColor("#afc9c9cb");

    GradientDrawable gd = new GradientDrawable();
    gd.setColor(fillColor);
    gd.setCornerRadius(roundRadius);
    gd.setStroke(strokeWidth, strokeColor);

    return gd;
}
项目:OSchina_resources_android    文件:IdentityView.java   
private void initBorder() {
//        if (mWipeOffBorder || mIdentity == null || !mIdentity.officialMember) {
//            mDrawable = null;
//            setBackground(null);
//            return;
//        }

        if (mDrawable == null) {
            float radius = 4f;

            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
            gradientDrawable.setShape(GradientDrawable.RECTANGLE);
            gradientDrawable.setDither(true);
            gradientDrawable.setStroke(STROKE_SIZE, mColor);
            gradientDrawable.setCornerRadius(radius);

            mDrawable = gradientDrawable;
        } else {
            mDrawable.setStroke(STROKE_SIZE, mColor);
        }

        setBackground(mDrawable);
    }
项目:GitHub    文件:OverlappedWidget.java   
@Override
protected void drawCurrentPageShadow(Canvas canvas) {
    canvas.save();
    GradientDrawable shadow;
    if (actiondownX > mScreenWidth >> 1) {
        shadow = mBackShadowDrawableLR;
        shadow.setBounds((int) (mScreenWidth + touch_down - 5), 0, (int) (mScreenWidth + touch_down + 5), mScreenHeight);

    } else {
        shadow = mBackShadowDrawableRL;
        shadow.setBounds((int) (touch_down - 5), 0, (int) (touch_down + 5), mScreenHeight);
    }
    shadow.draw(canvas);
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
项目:silly-android    文件:Coloring.java   
/**
 * Creates a new {@link RippleDrawable} introduced in Lollipop.
 *
 * @param normalColor  Color for the idle/normal state
 * @param rippleColor  Color for the ripple effect
 * @param bounds       Clipping bounds for the ripple state. Set to {@code null} to get a borderless ripple
 * @param cornerRadius Set to round the corners on rectangular drawables, 0 to disable
 * @return A fully colored RippleDrawable, new instance each time
 */
@NonNull
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static RippleDrawable createRippleDrawable(@ColorInt final int normalColor, @ColorInt final int rippleColor, @Nullable final Rect bounds,
                                                  @IntRange(from = 0) final int cornerRadius) {
    Drawable maskDrawable = null;
    if (bounds != null) {
        // clip color is white
        maskDrawable = createColoredDrawable(Color.WHITE, bounds);
        if (maskDrawable instanceof GradientDrawable) {
            ((GradientDrawable) maskDrawable).setCornerRadius(cornerRadius);
        }
        maskDrawable.setBounds(bounds);
    }

    Drawable normalStateDrawable = null;
    // transparent has no idle state
    if (normalColor != Color.TRANSPARENT) {
        normalStateDrawable = createColoredDrawable(normalColor, bounds);
        if (normalStateDrawable instanceof GradientDrawable) {
            ((GradientDrawable) normalStateDrawable).setCornerRadius(cornerRadius);
        }
    }

    return new RippleDrawable(ColorStateList.valueOf(rippleColor), normalStateDrawable, maskDrawable);
}
项目:RLibrary    文件:ViewfinderView.java   
public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    Resources resources = getResources();
    maskColor = Color.parseColor("#60000000");//resources.getColor(R.color.viewfinder_mask);
    resultColor = Color.parseColor("#b0000000");//resources.getColor(R.color.result_view);

    // GradientDrawable、lineDrawable
    mRect = new Rect();
    int left = Color.RED;//getResources().getColor(R.color.lightgreen);
    //getResources().getColor(R.color.green);
    //mCenterColor = Color.RED;
    setCenterColor(Color.RED);
    int right = Color.RED;//getResources().getColor(R.color.lightgreen);
    //lineDrawable = resources.getDrawable(R.drawable.zx_code_line);
    mDrawable = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, new int[]{left,
            left, mCenterColor, right, right});

    scannerAlpha = 0;
    possibleResultPoints = new ArrayList<>(5);
}
项目:Cable-Android    文件:LEDColorListPreference.java   
private void setPreviewColor(@NonNull String value) {
  int color;

  switch (value) {
    case "green":   color = getContext().getResources().getColor(R.color.green_500);   break;
    case "red":     color = getContext().getResources().getColor(R.color.red_500);     break;
    case "blue":    color = getContext().getResources().getColor(R.color.blue_500);    break;
    case "yellow":  color = getContext().getResources().getColor(R.color.yellow_500);  break;
    case "cyan":    color = getContext().getResources().getColor(R.color.cyan_500);    break;
    case "magenta": color = getContext().getResources().getColor(R.color.pink_500);    break;
    case "white":   color = getContext().getResources().getColor(R.color.white);       break;
    default:        color = getContext().getResources().getColor(R.color.transparent); break;
  }

  if (colorImageView != null) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(GradientDrawable.OVAL);
    drawable.setColor(color);

    colorImageView.setImageDrawable(drawable);
  }
}
项目:StarchWindow    文件:FlatToast.java   
public FlatToast(Context context) {
    super(context);
    mContext = context;

    //toast text
    textView = new TextView(context);
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(17);
    textView.setPadding(Utils.dip2px(context, 15), Utils.dip2px(context, 8), Utils.dip2px(context, 15), Utils.dip2px(context, 8));

    //toast background
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(Color.parseColor("#212121"));
    gradientDrawable.setAlpha(200);
    gradientDrawable.setCornerRadius(Utils.dip2px(context, 10));
}
项目:DereHelper    文件:MultiLineChooseLayout.java   
private void updateDrawable(int strokeColor) {

            int mbackgroundColor;
            if (isChecked) {
                mbackgroundColor = selectedBackgroundColor;
            } else {
                mbackgroundColor = backgroundColor;
            }

            GradientDrawable drawable = new GradientDrawable();
            drawable.setCornerRadii(mRadius);
            drawable.setColor(mbackgroundColor);
            drawable.setStroke(mStrokeWidth, strokeColor);

            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                this.setBackgroundDrawable(drawable);
            } else {
                this.setBackground(drawable);
            }
        }
项目:ultrasonic    文件:MenuDrawer.java   
protected GradientDrawable.Orientation getDropShadowOrientation() {
    // Gets the orientation for the static and sliding drawer. The overlay drawer provides its own implementation.
    switch (getPosition()) {
        case TOP:
            return GradientDrawable.Orientation.BOTTOM_TOP;

        case RIGHT:
            return GradientDrawable.Orientation.LEFT_RIGHT;

        case BOTTOM:
            return GradientDrawable.Orientation.TOP_BOTTOM;

        default:
            return GradientDrawable.Orientation.RIGHT_LEFT;
    }
}
项目:FriendBook    文件:SuperConfig.java   
private Drawable getGradientDrawable(float mCornerRadius,
                                     int mStrokeColor, int mSolidColor, int mStrokeWidth,
                                     float mDashWidth, float mDashGap,
                                     float mTopLeftRadius, float mTopRightRadius,
                                     float mBottomLeftRadius, float mBottomRightRadius) {
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(mSolidColor);
    gradientDrawable.setStroke(mStrokeWidth, mStrokeColor, mDashWidth, mDashGap);
    float[] radius = {mTopLeftRadius, mTopLeftRadius, mTopRightRadius, mTopRightRadius, mBottomRightRadius,
            mBottomRightRadius, mBottomLeftRadius, mBottomLeftRadius};

    if (mCornerRadius == DEFAULT_CORNER_RADIUS) {
        gradientDrawable.setCornerRadii(radius);
    } else {
        gradientDrawable.setCornerRadius(mCornerRadius);
    }
    return gradientDrawable;
}
项目:BlackList    文件:Utils.java   
/**
 * Sets the background color of the drawable
 **/
public static void setDrawableColor(Context context, Drawable drawable, @AttrRes int colorAttrRes) {
    int colorRes = getResourceId(context, colorAttrRes);
    int color = ContextCompat.getColor(context, colorRes);
    if (drawable instanceof ShapeDrawable) {
        ((ShapeDrawable) drawable).getPaint().setColor(color);
    } else if (drawable instanceof GradientDrawable) {
        ((GradientDrawable) drawable).setColor(color);
    } else if (drawable instanceof ColorDrawable) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ((ColorDrawable) drawable).setColor(color);
        }
    } else if (drawable instanceof RotateDrawable) {
        setDrawableColor(context, ((RotateDrawable) drawable).getDrawable(), colorAttrRes);
    }
}
项目:Material-Motion    文件:DotsFragment.java   
private AnimatorSet morphParent(int duration){
    GradientDrawable drawable=GradientDrawable.class.cast(parent.getBackground());
    int endValue=isFolded?getResources().getDimensionPixelOffset(R.dimen.morph_radius):0;
    ObjectAnimator cornerAnimation = ObjectAnimator.ofFloat(drawable, "cornerRadius", endValue);
    endValue=isFolded?parent.getHeight()/2:parent.getHeight()*2;
    ValueAnimator heightAnimation = ValueAnimator.ofInt(parent.getHeight(),endValue);
    heightAnimation.addUpdateListener(valueAnimator-> {
        int val = (Integer) valueAnimator.getAnimatedValue();
        ViewGroup.LayoutParams layoutParams = parent.getLayoutParams();
        layoutParams.height = val;
        parent.setLayoutParams(layoutParams);
    });
    cornerAnimation.setDuration(duration);
    heightAnimation.setDuration(duration);
    AnimatorSet set=new AnimatorSet();
    set.playTogether(cornerAnimation,heightAnimation);
    return set;
}
项目:BookPage    文件:BookPageView.java   
/**
 * 绘制A区域水平翻页阴影
 * @param canvas
 */
private void drawPathAHorizontalShadow(Canvas canvas, Path pathA){
    canvas.restore();
    canvas.save();
    canvas.clipPath(pathA, Region.Op.INTERSECT);

    int maxShadowWidth = 30;//阴影矩形最大的宽度
    int left = (int) (a.x - Math.min(maxShadowWidth,(rPathAShadowDis/2)));
    int right = (int) (a.x);
    int top = 0;
    int bottom = viewHeight;
    GradientDrawable gradientDrawable = drawableHorizontalLowerRight;
    gradientDrawable.setBounds(left,top,right,bottom);

    float mDegrees = (float) Math.toDegrees(Math.atan2(f.x-a.x,f.y-h.y));
    canvas.rotate(mDegrees, a.x, a.y);
    gradientDrawable.draw(canvas);
}
项目:BookPage    文件:CoverPageView.java   
private void init(Context context){
    defaultWidth = 600;
    defaultHeight = 1000;
    pageNum = 1;
    scrollPageLeft = 0;
    scrollTime = 300;
    touchStyle = TOUCH_RIGHT;
    pageState = PAGE_STAY;

    touchPoint = new MyPoint(-1,-1);
    mScroller = new Scroller(context,new LinearInterpolator());

    int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
    shadowDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    shadowDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
项目:XERUNG    文件:Switch.java   
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);
        }
    }
}
项目:FlickLauncher    文件:HeaderElevationController.java   
public ControllerV16(View header) {
    Resources res = header.getContext().getResources();
    mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);

    mShadow = new View(header.getContext());
    mShadow.setBackground(new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0x1E000000, 0x00000000}));
    mShadow.setAlpha(0);

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            res.getDimensionPixelSize(R.dimen.all_apps_header_shadow_height));
    lp.topMargin = ((FrameLayout.LayoutParams) header.getLayoutParams()).height;

    ((ViewGroup) header.getParent()).addView(mShadow, lp);
}
项目:TextReader    文件:OverlappedWidget.java   
@Override
protected void drawCurrentPageShadow(Canvas canvas) {
    canvas.save();
    GradientDrawable shadow;
    if (actiondownX > mScreenWidth >> 1) {
        shadow = mBackShadowDrawableLR;
        shadow.setBounds((int) (mScreenWidth + touch_down - 5), 0, (int) (mScreenWidth + touch_down + 5), mScreenHeight);

    } else {
        shadow = mBackShadowDrawableRL;
        shadow.setBounds((int) (touch_down - 5), 0, (int) (touch_down + 5), mScreenHeight);
    }
    shadow.draw(canvas);
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
项目:proSwipeButton    文件:ProSwipeButton.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    contentContainer = view.findViewById(R.id.relativeLayout_swipeBtn_contentContainer);
    arrowHintContainer = view.findViewById(R.id.linearLayout_swipeBtn_hintContainer);
    contentTv = view.findViewById(R.id.tv_btnText);
    arrow1 = view.findViewById(R.id.iv_arrow1);
    arrow2 = view.findViewById(R.id.iv_arrow2);

    tintArrowHint();
    contentTv.setText(btnText);
    contentTv.setTextColor(textColorInt);
    contentTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setShape(GradientDrawable.RECTANGLE);
    gradientDrawable.setCornerRadius(btnRadius);
    setBackgroundColor(bgColorInt);
    updateBackground();
    setupTouchListener();
}
项目:zabbkit-android    文件:EventsAdapter.java   
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder,
                             int position) {
    // retrieve the text view
    ItemViewHolder itemHolder = (ItemViewHolder) holder;
    TextView view = itemHolder.descriptionText;
    // replace text contents
    view.setText(mDataset.get(position).getString("description"));
    // replace list item's metadata
    holder.itemView.setTag(position);

    ImageView mCircle = itemHolder.priorityCircleImage;
    int result;
    int prior = Integer.valueOf(mDataset.get(position).getString("priority"));
    switch (prior) {
        case Constants.STATE_NOT_CLASSIFIED:
            result = R.color.not_classified_color;
            break;
        case Constants.STATE_INFORMATION:
            result = R.color.information_color;
            break;
        case Constants.STATE_WARNING:
            result = R.color.warning_color;
            break;
        case Constants.STATE_AVERAGE:
            result = R.color.average_color;
            break;
        case Constants.STATE_HIGH:
            result = R.color.high_color;
            break;
        case Constants.STATE_DISASTER:
            result = R.color.disaster_color;
            break;
        default:
            result = R.color.not_classified_color;
            break;
    }
    ((GradientDrawable) mCircle.getDrawable()).setColor(mContext.getResources().getColor(result));

}
项目:SimpleDialogFragments    文件:ColorView.java   
private Drawable createBackgroundColorDrawable() {
    GradientDrawable mask = new GradientDrawable();
    mask.setShape(GradientDrawable.OVAL);
    if (mOutlineWidth != 0) {
        mask.setStroke(mOutlineWidth, isColorDark(mColor) ? Color.WHITE : Color.BLACK);
    }
    mask.setColor(mColor);
    return mask;
}
项目:dotsindicator    文件:DotsIndicator.java   
private void setUpCircleColors(int color) {
  if (dots != null) {
    for (ImageView elevationItem : dots) {
      ((GradientDrawable) elevationItem.getBackground()).setColor(color);
    }
  }
}
项目:sealtalk-android-master    文件:DragPointView.java   
/**
 * @param radius 圆角角度
 * @param color  填充颜色
 * @return StateListDrawable 对象
 * @author zy
 */
public static StateListDrawable createStateListDrawable(int radius, int color) {
    StateListDrawable bg = new StateListDrawable();
    GradientDrawable gradientStateNormal = new GradientDrawable();
    gradientStateNormal.setColor(color);
    gradientStateNormal.setShape(GradientDrawable.RECTANGLE);
    gradientStateNormal.setCornerRadius(50);
    gradientStateNormal.setStroke(0, 0);
    bg.addState(View.EMPTY_STATE_SET, gradientStateNormal);
    return bg;
}
项目:fuckView    文件:RedBoundPopupWindow.java   
@Override
protected View onCreateView(Context context) {
    absoluteLayout = new AbsoluteLayout(context);
    GradientDrawable gd = new GradientDrawable();
    gd.setStroke(4, Color.RED);
    absoluteLayout.setBackgroundDrawable(gd);
    return absoluteLayout;
}
项目:AndroidUiKit    文件:IDividerItemDecoration.java   
/**
 * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
 * {@link LinearLayoutManager}.
 *
 * @param context Current context, it will be used to access resources.
 * @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
 */
public IDividerItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = new GradientDrawable();
    //默认divider 1dp
    mVerticalDividerHeight = DimenUtil.dp2px(context, 1);
    mHorizontalDividerWidth = DimenUtil.dp2px(context, 1);
    mDividerColor = Color.parseColor("lightgrey");
    a.recycle();
    setOrientation(orientation);
}
项目:GitHub    文件:TextBadgeItem.java   
/**
 * @param context to fetch color
 * @return return the background drawable
 */
private GradientDrawable getBadgeDrawable(Context context) {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadius(context.getResources().getDimensionPixelSize(R.dimen.badge_corner_radius));
    shape.setColor(getBackgroundColor(context));
    shape.setStroke(getBorderWidth(), getBorderColor(context));
    return shape;
}
项目:ExpandButton    文件:ExpandButtonLayout.java   
/**
 * 设置圆角背景
 */
private void initBackGround(){
    int fillColor = getResources().getColor(R.color.colorPrimary);
    GradientDrawable gd = new GradientDrawable();//创建drawable
    gd.setColor(fillColor);
    //圆角半径等于高度的一半,合成之后是一个完整的圆
    gd.setCornerRadius(allHeight/2f);
    gd.getPadding(new Rect(0,0,0,0));
    setBackground(gd);
}
项目:ColorView    文件:ColorViewHelper.java   
private boolean updatePressed(boolean forceToColorMode) {
    if (forceToColorMode) {
        mDrawablePressed = createDrawable(mDrawablePressed, mBgColorPressed, mBdColorPressed, true);
    } else {
        if (mDrawablePressed instanceof GradientDrawable) {
            mDrawablePressed = createDrawable(mDrawablePressed, mBgColorPressed, mBdColorPressed, false);
        } else {
            return false;
        }
    }

    return true;
}
项目:PlusGram    文件:ProfileActivity.java   
private void updateActionBarBG(){
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
    int hColor = themePrefs.getInt("profileHeaderColor", def);
    actionBar.setBackgroundColor(hColor);
    listView.setGlowColor(hColor);
    topViewColor = hColor;
    int val = themePrefs.getInt("profileHeaderGradient", 0);
    if (val > 0) {
        topViewColor = 0x00000000;
        int gradColor = themePrefs.getInt("profileHeaderGradientColor", def);
        GradientDrawable.Orientation go;
        switch (val) {
            case 2:
                go = GradientDrawable.Orientation.LEFT_RIGHT;
                break;
            case 3:
                go = GradientDrawable.Orientation.TL_BR;
                break;
            case 4:
                go = GradientDrawable.Orientation.BL_TR;
                break;
            default:
                go = GradientDrawable.Orientation.TOP_BOTTOM;
                topViewColor = gradColor;
        }
        int[] colors = new int[]{hColor, gradColor};
        GradientDrawable actionBarGradient = new GradientDrawable(go, colors);
        actionBar.setBackgroundDrawable(actionBarGradient);
    }
    topView.setBackgroundColor(topViewColor);
}
项目:FlipProgressDialog    文件:BackgroundView.java   
public static Drawable setBackground(View v, int color, int borderColor, int r, int borderStroke) {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadii(new float[] { r, r, r, r, r, r, r, r });
    shape.setColor(color);
    shape.setStroke(borderStroke, borderColor);
    return shape;
}
项目:HeadlineNews    文件:SelectorFactory.java   
private GradientDrawable getItemShape(int shape, int cornerRadius,
                                      int solidColor, int strokeWidth, int strokeColor) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(shape);
    drawable.setStroke(strokeWidth, strokeColor);
    drawable.setCornerRadius(cornerRadius);
    drawable.setColor(solidColor);
    return drawable;
}
项目:GitHub    文件:WoWoLayerListColorAnimation.java   
private void setColors(View view, int[] colors) {
    Drawable drawable = view.getBackground();
    if (drawable instanceof LayerDrawable) {
        LayerDrawable layerDrawable = (LayerDrawable) drawable;
        for (int i = 0; i < colors.length; i++) if (layerDrawable.getDrawable(i) instanceof GradientDrawable) ((GradientDrawable) layerDrawable.getDrawable(i)).setColor(colors[i]);
    } else Log.w(TAG, "Drawable of view must be LayerDrawable in WoWoLayerListColorAnimation");
}
项目:Tangram-Android    文件:BannerView.java   
private GradientDrawable getGradientDrawable(int color, float radius) {
    GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
        new int[]{color, color});
    gradientDrawable.setShape(GradientDrawable.OVAL);
    gradientDrawable.setCornerRadius(radius);
    return gradientDrawable;
}
项目:cwac-crossport    文件:FloatingActionButtonImpl.java   
void setBackgroundDrawable(ColorStateList backgroundTint,
        PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) {
    // Now we need to tint the original background with the tint, using
    // an InsetDrawable if we have a border width
    mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode);
    }

    // Now we created a mask Drawable which will be used for touch feedback.
    GradientDrawable touchFeedbackShape = createShapeDrawable();

    // We'll now wrap that touch feedback mask drawable with a ColorStateList. We do not need
    // to inset for any border here as LayerDrawable will nest the padding for us
    mRippleDrawable = DrawableCompat.wrap(touchFeedbackShape);
    DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor));

    final Drawable[] layers;
    if (borderWidth > 0) {
        mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        layers = new Drawable[] {mBorderDrawable, mShapeDrawable, mRippleDrawable};
    } else {
        mBorderDrawable = null;
        layers = new Drawable[] {mShapeDrawable, mRippleDrawable};
    }

    mContentBackground = new LayerDrawable(layers);

    mShadowDrawable = new ShadowDrawableWrapper(
            mView.getContext(),
            mContentBackground,
            mShadowViewDelegate.getRadius(),
            mElevation,
            mElevation + mPressedTranslationZ);
    mShadowDrawable.setAddPaddingForCorners(false);
    mShadowViewDelegate.setBackgroundDrawable(mShadowDrawable);
}
项目:boohee_v5.6    文件:WeightDetailAdapter.java   
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(this.context).inflate(R.layout.jm, parent, false);
    }
    final ScaleIndex itemData = (ScaleIndex) getItem(position);
    TextView amount = (TextView) convertView.findViewById(R.id.tv_amount);
    TextView level = (TextView) convertView.findViewById(R.id.tv_level);
    ((TextView) convertView.findViewById(R.id.tv_name)).setText(itemData.getName());
    amount.setText(itemData.getValueWithUnit());
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(ViewCompat.MEASURED_SIZE_MASK);
    drawable.setCornerRadius(this.outerR[0]);
    drawable.setStroke(1, itemData.getColor());
    level.setBackgroundDrawable(drawable);
    level.setTextColor(itemData.getColor());
    level.setText(itemData.getLevelName());
    if (itemData instanceof FakeIndex) {
        convertView.setOnClickListener(null);
    } else {
        convertView.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                WeightDetailAdapter.this.mFragment.getDialog().getWindow()
                        .setWindowAnimations(R.style.df);
                ScaleIndexActivity.startActivity(WeightDetailAdapter.this.context,
                        WeightDetailAdapter.this.mRecord, itemData.getName());
            }
        });
    }
    return convertView;
}
项目:NovelReader    文件:CoverPageAnim.java   
public CoverPageAnim(int w, int h, View view, OnPageChangeListener listener) {
    super(w, h, view, listener);
    mSrcRect = new Rect(0, 0, mViewWidth, mViewHeight);
    mDestRect = new Rect(0, 0, mViewWidth, mViewHeight);
    int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
项目:underlx    文件:LineRecyclerViewAdapter.java   
private void setDownGradient(final ViewHolder holder) {
    GradientDrawable gd = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT,
            new int[]{holder.mItem.color, darkerColor(holder.mItem.color)});
    if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        holder.mView.setBackgroundDrawable(gd);
    } else {
        holder.mView.setBackground(gd);
    }
}
项目:NodeET    文件:CategoryListFragment.java   
CategoryViewHolder(View itemView) {
    super(itemView);
    //第一个参数是注解所在的对象。第二个参数是View。
    ButterKnife.bind(this, itemView);
    icon.setTypeface(Typefaces.getAwesomeFont(getContext()));
    iconBackground = (GradientDrawable) icon.getBackground();
}
项目:RetroMusicPlayer    文件:DrawableGradient.java   
public DrawableGradient(Orientation orientations, int[] colors, int shape) {
    super(orientations, colors);
    try {
        setShape(shape);
        setGradientType(GradientDrawable.LINEAR_GRADIENT);
        setCornerRadius(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:stynico    文件:ColorPointHintView.java   
@Override
   public Drawable makeFocusDrawable()
{
       GradientDrawable dot_focus = new GradientDrawable();
       dot_focus.setColor(focusColor);
       dot_focus.setCornerRadius(dump.v.Util.dip2px(getContext(), 4));
       dot_focus.setSize(dump.v.Util.dip2px(getContext(), 8), dump.v.Util.dip2px(getContext(), 8));
       return dot_focus;
   }
项目:ColorView    文件:ColorViewHelper.java   
private boolean updateChecked(boolean forceToColorMode) {
    if (forceToColorMode) {
        mDrawableChecked = createDrawable(mDrawableChecked, mBgColorChecked, mBdColorChecked, true);
    } else {
        if (mDrawableChecked instanceof GradientDrawable) {
            mDrawableChecked = createDrawable(mDrawableChecked, mBgColorChecked, mBdColorChecked, false);
        } else {
            return false;
        }
    }

    return true;
}