use of android.graphics.drawable.GradientDrawable in project Signal-Android by WhisperSystems.
the class BubbleDrawableBuilder method create.
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;
}
}
use of android.graphics.drawable.GradientDrawable in project AndroidRubberIndicator by LyndonChin.
the class RubberIndicator method init.
private void init(AttributeSet attrs, int defStyle) {
/** Get XML attributes */
final TypedArray styledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.RubberIndicator, defStyle, 0);
mSmallCircleColor = styledAttributes.getColor(R.styleable.RubberIndicator_smallCircleColor, DEFAULT_SMALL_CIRCLE_COLOR);
mLargeCircleColor = styledAttributes.getColor(R.styleable.RubberIndicator_largeCircleColor, DEFAULT_LARGE_CIRCLE_COLOR);
mOuterCircleColor = styledAttributes.getColor(R.styleable.RubberIndicator_outerCircleColor, DEFAULT_OUTER_CIRCLE_COLOR);
styledAttributes.recycle();
/** Initialize views */
View rootView = inflate(getContext(), R.layout.rubber_indicator, this);
mContainer = (LinearLayout) rootView.findViewById(R.id.container);
mOuterCircle = (CircleView) rootView.findViewById(R.id.outer_circle);
// Apply outer color to outerCircle and background shape
View containerWrapper = rootView.findViewById(R.id.container_wrapper);
mOuterCircle.setColor(mOuterCircleColor);
GradientDrawable shape = (GradientDrawable) containerWrapper.getBackground();
shape.setColor(mOuterCircleColor);
/** values */
mSmallCircleRadius = dp2px(SMALL_CIRCLE_RADIUS);
mLargeCircleRadius = dp2px(LARGE_CIRCLE_RADIUS);
mOuterCircleRadius = dp2px(OUTER_CIRCLE_RADIUS);
/** animators */
mPvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1, 0.8f, 1);
mPvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1, 0.8f, 1);
mPvhScale = PropertyValuesHolder.ofFloat("scaleY", 1, 0.5f, 1);
mPvhRotation = PropertyValuesHolder.ofFloat("rotation", 0);
mSmallCirclePath = new Path();
mPendingAnimations = new LinkedList<>();
/** circle view list */
mCircleViews = new ArrayList<>();
}
use of android.graphics.drawable.GradientDrawable in project BoomMenu by Nightonke.
the class Ham method init.
@Override
public void init(int color) {
Drawable backgroundDrawable = Util.getDrawable(this, R.drawable.piece_ham, null);
((GradientDrawable) backgroundDrawable).setColor(color);
Util.setDrawable(this, backgroundDrawable);
}
use of android.graphics.drawable.GradientDrawable in project BoomMenu by Nightonke.
the class Util method getOvalDrawable.
public static GradientDrawable getOvalDrawable(View view, int color) {
GradientDrawable gradientDrawable = (GradientDrawable) getDrawable(view, R.drawable.shape_oval_normal);
gradientDrawable.setColor(color);
return gradientDrawable;
}
use of android.graphics.drawable.GradientDrawable in project Signal-Android by WhisperSystems.
the class ColorPreference method setColorViewValue.
private static void setColorViewValue(View view, int color, boolean selected) {
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
Resources res = imageView.getContext().getResources();
Drawable currentDrawable = imageView.getDrawable();
GradientDrawable colorChoiceDrawable;
if (currentDrawable instanceof GradientDrawable) {
// Reuse drawable
colorChoiceDrawable = (GradientDrawable) currentDrawable;
} else {
colorChoiceDrawable = new GradientDrawable();
colorChoiceDrawable.setShape(GradientDrawable.OVAL);
}
// Set stroke to dark version of color
// int darkenedColor = Color.rgb(
// Color.red(color) * 192 / 256,
// Color.green(color) * 192 / 256,
// Color.blue(color) * 192 / 256);
colorChoiceDrawable.setColor(color);
// colorChoiceDrawable.setStroke((int) TypedValue.applyDimension(
// TypedValue.COMPLEX_UNIT_DIP, 2, res.getDisplayMetrics()), darkenedColor);
Drawable drawable = colorChoiceDrawable;
if (selected) {
BitmapDrawable checkmark = (BitmapDrawable) res.getDrawable(R.drawable.check);
checkmark.setGravity(Gravity.CENTER);
drawable = new LayerDrawable(new Drawable[] { colorChoiceDrawable, checkmark });
}
imageView.setImageDrawable(drawable);
} else if (view instanceof TextView) {
((TextView) view).setTextColor(color);
}
}
Aggregations