2013-12-19 31 views
1

最近我開發了棋盤遊戲(https://play.google.com/store/apps/details?id=com.pradhan.manoj.CoinStack)。它在所有安卓設備上都能正常工作,除了少數那些擁有高清顯示功能的手機,包括Micromax Canvas HD和Samsung Galaxy Grand。我一直在找出我在做錯什麼時遇到困難。下面是代碼提取...Android:DrawRect不會顯示在高清手機的畫布上

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); 

您的專家意見/建議,以指出這個問題是高度讚賞。

+0

相同問題。如果我畫圓圈很好,但不適用於矩形。 – Xenione

回答

0

可能的解決方案:檢查座標的差異 - 它不應該是負面的。

+1

不知道誰低估了這一點,但這似乎是正確的。在較老的API中,可以從高到低繪製新的API,但該對象不會繪製。 – David

1

我面臨同樣的問題。

例如較老的API繪製當前代碼

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

但是,新的API不畫任何東西

要修復它

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

將繪製

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