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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations