I found a solution, here's what i ended up with. Takes a ArrayList of Colors as parameter, and if the arraylist have more than one color it draws two triangles with each color. If not it makes a square with the first color
public class ColorBox extends View {
Paint paint = new Paint();
String color1;
String color2;
public ColorBox(Context context, ArrayList<String> colors) {
super(context);
if(colors.size() == 1){
color1 = colors.get(0);
}
else{
color1 = colors.get(0);
color2 = colors.get(1);
}
}
@Override
public void onDraw(Canvas canvas) {
Point topLeft = new Point(7, 7);
Point topRight = new Point(7, 62);
Point bottomLeft = new Point(62, 7);
Point bottomRight = new Point(62, 62);
//This draw a thin line around the border, with line width 1
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1f);
canvas.drawRect(5, 5, 65, 65, paint);
paint.setColor(Color.parseColor(color1));
paint.setStrokeWidth(1);
paint.setStyle(Paint.Style.FILL);
if(color2 != null && !color2.isEmpty()) //Two Colors
{
//Draw Top Left Color
Path path1 = new Path();
path1.setFillType(Path.FillType.EVEN_ODD);
path1.moveTo(topLeft.x, topLeft.x);
path1.lineTo(topRight.x, topRight.y);
path1.lineTo(bottomLeft.x, bottomLeft.y);
path1.lineTo(topLeft.x, topLeft.y);
path1.close();
canvas.drawPath(path1, paint);
//Draw Bottom Right Color
paint.setColor(Color.parseColor(color2));
Path path2 = new Path();
path2.setFillType(Path.FillType.EVEN_ODD);
path2.moveTo(topRight.x, topRight.y);
path2.lineTo(bottomLeft.x, bottomLeft.y);
path2.lineTo(bottomRight.x, bottomRight.y);
path2.lineTo(topRight.x, topRight.y);
path2.close();
canvas.drawPath(path2, paint);
}
else {
canvas.drawRect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y, paint);
}
}