Search in sources :

Example 61 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project StyleableToast by Muddz.

the class StyleableToast method getShape.

// ____________________ PUBLIC METHODS ENDS ________________________
private GradientDrawable getShape() {
    getShapeAttributes();
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setCornerRadius(getTypedValueInDP(context, cornerRadius));
    gradientDrawable.setStroke((int) getTypedValueInDP(context, strokeWidth), strokeColor);
    gradientDrawable.setColor(backgroundColor);
    gradientDrawable.setAlpha(alpha);
    return gradientDrawable;
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 62 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project pictureapp by EyeSeeTea.

the class BaseLayoutUtils method highlightSelection.

/**
     * @param view
     * @param option
     */
public static void highlightSelection(View view, Option option) {
    Drawable selectedBackground = view.getContext().getResources().getDrawable(R.drawable.background_dynamic_clicked_option);
    if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        //JELLY_BEAN=API16
        view.setBackground(selectedBackground);
    } else {
        view.setBackgroundDrawable(selectedBackground);
    }
    if (option != null) {
        GradientDrawable bgShape = (GradientDrawable) view.getBackground();
        String backGColor = option.getOptionAttribute() != null ? option.getOptionAttribute().getBackground_colour() : option.getBackground_colour();
        bgShape.setColor(Color.parseColor("#" + backGColor));
        bgShape.setStroke(3, Color.WHITE);
    }
    //the view is a framelayout with a imageview, or a imageview, or a custombutton
    ImageView imageView = null;
    if (view instanceof FrameLayout) {
        FrameLayout f = (FrameLayout) view;
        imageView = (ImageView) f.getChildAt(0);
    } else if (view instanceof ImageView) {
        imageView = (ImageView) view;
    }
    if (imageView != null) {
        imageView.clearColorFilter();
    }
}
Also used : FrameLayout(android.widget.FrameLayout) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 63 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.

the class PhoneConfirmationButton method setState.

public void setState(State state) {
    this.state = state;
    switch(state) {
        case NONE:
            setBackground(null);
            setText("");
            setClickable(false);
            setVisibility(View.GONE);
            break;
        case INVALID:
            setBackground(null);
            setText("");
            setClickable(false);
            setVisibility(View.VISIBLE);
            break;
        case CONFIRM:
            setClickable(true);
            GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TL_BR, new int[] { accentColor, accentColor, accentColor });
            gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
            gradientDrawable.setCornerRadii(new float[] { 0, 0, cornerRadius, cornerRadius, cornerRadius, cornerRadius, 0, 0 });
            setBackground(gradientDrawable);
            setText(nextGlyph);
            setVisibility(View.VISIBLE);
            break;
    }
    invalidate();
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 64 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.

the class OnBoardingHintFragment method onAccentColorHasChanged.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  AccentColorObserver
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onAccentColorHasChanged(Object sender, int color) {
    if (hintContainer == null) {
        return;
    }
    GradientDrawable circleDrawable = (GradientDrawable) hintContainer.getBackground();
    circleDrawable.setColor(color);
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 65 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.

the class ConfirmationMenu method getButtonBackground.

private Drawable getButtonBackground(int borderColor, int fillColor, int strokeWidth, int cornerRadius) {
    int fillColorPressed = getPressColor(PRESSED_ALPHA, fillColor);
    int borderColorPressed = getPressColor(PRESSED_ALPHA, borderColor);
    GradientDrawable gradientDrawablePressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { fillColorPressed, fillColorPressed });
    gradientDrawablePressed.setStroke(strokeWidth, borderColorPressed);
    gradientDrawablePressed.setCornerRadius(cornerRadius);
    GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { fillColor, fillColor });
    gradientDrawable.setStroke(strokeWidth, borderColor);
    gradientDrawable.setCornerRadius(cornerRadius);
    StateListDrawable states = new StateListDrawable();
    states.addState(new int[] { android.R.attr.state_pressed }, gradientDrawablePressed);
    states.addState(new int[] { android.R.attr.state_focused }, gradientDrawablePressed);
    states.addState(new int[] {}, gradientDrawable);
    return states;
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable)

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