2

Lately I have developed the Board Game ( https://play.google.com/store/apps/details?id=com.pradhan.manoj.CoinStack ). It is working fine in all Android powered devices except few phones those are having HD display including Micromax Canvas HD and Samsung Galaxy Grand. I have been finding difficulty in figuring out what I have been doing wrong. Below is an extract from the code...

  rectPaint = new Paint();
  rectPaint.setAntiAlias(true);
  rectPaint.setDither(true);
  rectPaint.setColor(Color.BLACK);
  rectPaint.setStyle(Paint.Style.STROKE);
  rectPaint.setStrokeJoin(Paint.Join.ROUND);
  rectPaint.setStrokeCap(Paint.Cap.ROUND);

  //CurrentX, CurrentY are calculated dynamically

  rectPaint.setStyle(Paint.Style.FILL);
  canvas.drawRect(currentX,currentY,currentX+cellWidth,currentY-cellHeight,rectPaint);
  rectPaint.setStyle(Paint.Style.STROKE);
  rectPaint.setColor(Color.BLUE);
  canvas.drawRect(currentX,currentY,currentX+cellWidth,currentY-cellHeight,rectPaint);

Your expert advice/suggestion to nail down this issue is highly appreciated.

stevenspiel
  • 5,775
  • 13
  • 60
  • 89
mkp77
  • 21
  • 4

2 Answers2

2

Possible solution: check the difference of the coordinates - it should not be negative.

AntonyX
  • 29
  • 4
  • 1
    Not sure who downvoted this, but this seems to be correct. In older APIs, it is possible to draw from high to low, on new APIs, the object doesn't draw. – David Oct 10 '14 at 04:40
2

I was faced with the same problem.

For example older APIs drawn current code

Rect r1 = new Rect(631 , 576 , 702, 283 );
canvas.drawRect(r1,paintP);

But new API is not drawing anything

To fix it

Right coordinates must be greater the left
Bottom coordinates must be greater the top 

It will be drawn

Rect r1 = new Rect(631 ,  283 , 702, 576 );
canvas.drawRect(r1,paintP);
AC1D
  • 248
  • 5
  • 16