Search in sources :

Example 26 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project instructure-android by instructure.

the class CourseColorAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.course_color, null);
        viewHolder = new ViewHolder();
        viewHolder.courseColor = convertView.findViewById(R.id.course_color);
        convertView.setTag(viewHolder);
    }
    viewHolder = (ViewHolder) convertView.getTag();
    int currentColor = resources.getColor(courseColors[position]);
    viewHolder.courseColor.setBackgroundColor(currentColor);
    // that a new color can be selected.
    if (currentColor == CanvasContextColor.getCachedColor(context, canvasContext.getContextId())) {
        // make a circle, fill it with the current color that we are
        // looping through
        ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
        drawable.getPaint().setColor(currentColor);
        drawable.getPaint().setStyle(Paint.Style.FILL);
        drawable.getPaint().setAntiAlias(true);
        // set the circle as the background of the table row item
        viewHolder.courseColor.setBackgroundDrawable(drawable);
    }
    return convertView;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) Paint(android.graphics.Paint)

Example 27 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project instructure-android by instructure.

the class BaseBinder method createIndicatorBackground.

public static ShapeDrawable createIndicatorBackground(int color) {
    ShapeDrawable circle = new ShapeDrawable(new OvalShape());
    circle.getPaint().setColor(color);
    return circle;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 28 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project instructure-android by instructure.

the class CourseColorAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.course_color, null);
        viewHolder = new ViewHolder();
        viewHolder.courseColor = convertView.findViewById(R.id.course_color);
        convertView.setTag(viewHolder);
    }
    viewHolder = (ViewHolder) convertView.getTag();
    int currentColor = resources.getColor(courseColors[position]);
    viewHolder.courseColor.setBackgroundColor(currentColor);
    // that a new color can be selected.
    if (currentColor == CanvasContextColor.getColorForCourse(context, canvasContext)) {
        // make a circle, fill it with the current color that we are
        // looping through
        ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
        drawable.getPaint().setColor(currentColor);
        drawable.getPaint().setStyle(Paint.Style.FILL);
        drawable.getPaint().setAntiAlias(true);
        // set the circle as the background of the table row item
        viewHolder.courseColor.setBackgroundDrawable(drawable);
    }
    return convertView;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) Paint(android.graphics.Paint)

Example 29 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project android_packages_apps_crDroidSettings by crdroidandroid.

the class FloatingActionButton method createInnerStrokesDrawable.

private Drawable createInnerStrokesDrawable(final int color, float strokeWidth) {
    if (!mStrokeVisible) {
        return new ColorDrawable(Color.TRANSPARENT);
    }
    ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
    final int bottomStrokeColor = darkenColor(color);
    final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
    final int topStrokeColor = lightenColor(color);
    final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);
    final Paint paint = shapeDrawable.getPaint();
    paint.setAntiAlias(true);
    paint.setStrokeWidth(strokeWidth);
    paint.setStyle(Style.STROKE);
    shapeDrawable.setShaderFactory(new ShaderFactory() {

        @Override
        public Shader resize(int width, int height) {
            return new LinearGradient(width / 2, 0, width / 2, height, new int[] { topStrokeColor, topStrokeColorHalfTransparent, color, bottomStrokeColorHalfTransparent, bottomStrokeColor }, new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f }, TileMode.CLAMP);
        }
    });
    return shapeDrawable;
}
Also used : LinearGradient(android.graphics.LinearGradient) ShaderFactory(android.graphics.drawable.ShapeDrawable.ShaderFactory) ColorDrawable(android.graphics.drawable.ColorDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint) OvalShape(android.graphics.drawable.shapes.OvalShape) Shader(android.graphics.Shader) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 30 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project android_packages_apps_crDroidSettings by crdroidandroid.

the class FloatingActionButton method createCircleDrawable.

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;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint) OvalShape(android.graphics.drawable.shapes.OvalShape) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Aggregations

ShapeDrawable (android.graphics.drawable.ShapeDrawable)131 OvalShape (android.graphics.drawable.shapes.OvalShape)64 Paint (android.graphics.Paint)38 Drawable (android.graphics.drawable.Drawable)30 LayerDrawable (android.graphics.drawable.LayerDrawable)28 SuppressLint (android.annotation.SuppressLint)20 RoundRectShape (android.graphics.drawable.shapes.RoundRectShape)20 StateListDrawable (android.graphics.drawable.StateListDrawable)18 ClipDrawable (android.graphics.drawable.ClipDrawable)17 Bitmap (android.graphics.Bitmap)16 BitmapDrawable (android.graphics.drawable.BitmapDrawable)16 BitmapShader (android.graphics.BitmapShader)15 AnimationDrawable (android.graphics.drawable.AnimationDrawable)14 ColorDrawable (android.graphics.drawable.ColorDrawable)11 RectShape (android.graphics.drawable.shapes.RectShape)10 Resources (android.content.res.Resources)8 Shape (android.graphics.drawable.shapes.Shape)8 Canvas (android.graphics.Canvas)6 Shader (android.graphics.Shader)6 ImageView (android.widget.ImageView)6