Question

I have a list of path objects which are rectangles stored in an arraylist.

This is my code as shown below:

    for (RectF rec : rects) {

        for( int i =0; i< rects.size(); i++){

            System.out.println(rects.get(i).height() + "g");
            while(rects.get(i).height() !=50 ){

                canvas.drawRect(rec, paint);
            }
                canvas.drawOval(rec, paint);

            }

    }

Basically, when the rectangle height is not equal to 50, I would like to draw an oval instead of a rectangle. Upon running the code above, both the oval and rectangle was drawn. What is wrong here? Please help thank you.

Was it helpful?

Solution

for (RectF rec : rects) {
    System.out.println(rec.height() + "g");

    if(rec.height() != 50)
    {
        canvas.drawOval(rec, paint);
    }
    else
    {
        canvas.drawRect(rec, paint);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top