Search in sources :

Example 81 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project Shuttle by timusus.

the class SuggestedHeaderButton method init.

void init() {
    backgroundDrawable = new GradientDrawable();
    backgroundDrawable.setCornerRadius(ResourceUtils.toPixels(2));
    setBackground(backgroundDrawable);
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 82 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project Tangram-Android by alibaba.

the class LinearScrollView method setViewColor.

private void setViewColor(View view, int color) {
    if (view.getBackground() instanceof GradientDrawable) {
        GradientDrawable drawable = (GradientDrawable) view.getBackground().mutate();
        drawable.setColor(color);
    }
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 83 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project BottomNavigation by Ashok-Varma.

the class TextBadgeItem method getBadgeDrawable.

/**
 * @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;
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 84 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project MaterialAbout by jrvansuita.

the class AboutView method setDivider.

@SuppressWarnings("ResourceAsColor")
private void setDivider(AboutBuilder bundle, View holder) {
    if (bundle.isShowDivider()) {
        int color = bundle.getDividerColor();
        if (color == 0)
            color = isDarker() ? Color.GRAY : getNameColor();
        GradientDrawable drawable = ((GradientDrawable) ((LayerDrawable) holder.getBackground()).findDrawableByLayerId(R.id.stroke));
        if (drawable != null) {
            drawable.setStroke(bundle.getDividerHeight(), color, bundle.getDividerDashWidth(), bundle.getDividerDashGap());
        }
    } else {
        RippleUtil.background(holder, (Drawable) null);
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 85 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project JustAndroid by chinaltz.

the class AbWheelView method initResourcesIfNecessary.

/**
	 * Initializes resources.
	 */
private void initResourcesIfNecessary() {
    if (itemsPaint == null) {
        itemsPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
        // itemsPaint.density = getResources().getDisplayMetrics().density;
        itemsPaint.setTextSize(valueTextSize);
    }
    if (valuePaint == null) {
        valuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.DITHER_FLAG);
        // valuePaint.density = getResources().getDisplayMetrics().density;
        valuePaint.setTextSize(valueTextSize);
    }
    if (labelPaint == null) {
        labelPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.DITHER_FLAG);
        labelPaint.setTextSize(labelTextSize);
        //设置阴影
        labelPaint.setShadowLayer(0.5f, 0, 1, 0xFFFFFFFF);
    }
    //如果没设置中间的选中条用默认的颜色
    if (centerSelectDrawable == null) {
        GradientDrawable mGradientDrawable = new GradientDrawable(Orientation.BOTTOM_TOP, centerSelectGradientColors);
        mGradientDrawable.setStroke(centerSelectStrokeWidth, centerSelectStrokeColor);
        centerSelectDrawable = mGradientDrawable;
    }
    //上边界渐变层
    if (topShadow == null) {
        topShadow = new GradientDrawable(Orientation.TOP_BOTTOM, SHADOWS_COLORS);
    }
    //下边界渐变层
    if (bottomShadow == null) {
        bottomShadow = new GradientDrawable(Orientation.BOTTOM_TOP, SHADOWS_COLORS);
    }
    if (this.getBackground() == null) {
        //原来用颜色渐变实现setBackgroundDrawable(layerDrawable);
        //底部的颜色
        GradientDrawable mGradientDrawable1 = new GradientDrawable(Orientation.TOP_BOTTOM, topGradientColors);
        GradientDrawable mGradientDrawable2 = new GradientDrawable(Orientation.BOTTOM_TOP, bottomGradientColors);
        mGradientDrawable1.setStroke(topStrokeWidth, topStrokeColor);
        mGradientDrawable1.setShape(GradientDrawable.RECTANGLE);
        mGradientDrawable2.setShape(GradientDrawable.RECTANGLE);
        mGradientDrawable1.setGradientType(GradientDrawable.LINEAR_GRADIENT);
        mGradientDrawable2.setGradientType(GradientDrawable.LINEAR_GRADIENT);
        GradientDrawable[] mDrawables = new GradientDrawable[2];
        mDrawables[0] = mGradientDrawable1;
        mDrawables[1] = mGradientDrawable2;
        LayerDrawable layerDrawable = new LayerDrawable(mDrawables);
        //第一个参数0代表数组的第1个元素
        layerDrawable.setLayerInset(0, 0, 0, 0, 0);
        //第一个参数1代表数组的第2个元素
        layerDrawable.setLayerInset(1, 4, 1, 4, 1);
        setBackgroundDrawable(layerDrawable);
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) TextPaint(android.text.TextPaint)

Aggregations

GradientDrawable (android.graphics.drawable.GradientDrawable)169 Paint (android.graphics.Paint)19 Drawable (android.graphics.drawable.Drawable)19 StateListDrawable (android.graphics.drawable.StateListDrawable)19 View (android.view.View)19 SuppressLint (android.annotation.SuppressLint)18 TextView (android.widget.TextView)18 LayerDrawable (android.graphics.drawable.LayerDrawable)16 ImageView (android.widget.ImageView)14 LinearLayout (android.widget.LinearLayout)12 TypedArray (android.content.res.TypedArray)8 FrameLayout (android.widget.FrameLayout)6 TimeAnimator (android.animation.TimeAnimator)5 Typeface (android.graphics.Typeface)5 LayoutInflater (android.view.LayoutInflater)5 ViewGroup (android.view.ViewGroup)5 Attributes (com.cengalabs.flatui.Attributes)5 Resources (android.content.res.Resources)4 TextPaint (android.text.TextPaint)4 Button (android.widget.Button)4