我使用圓形,圓弧和線條在畫布上繪製了一張基本史密斯圓圖。我已經在很多大小的仿真器屏幕上運行了應用程序,並且所有工作都很完美,但是一旦我在實際設備上嘗試了它(Android 2.3.5),圖表就不會排隊,因爲它應該是某些對象不合適的位置。在仿真器上繪製圖表很好,但不是在手機上
編寫代碼時,我非常小心地使用get.Width()和get.Height()作爲參數,而不是使用像素,以便應用程序可以在所有設備上正常工作。下面是我使用的代碼示例:
canvas.drawCircle(canvas.getWidth()*1/2, canvas.getHeight()*3/8, canvas.getWidth()*475/1000, black);
canvas.drawCircle(canvas.getWidth()*5/8, canvas.getWidth()*5/8, canvas.getWidth()*349/1000, black);
canvas.drawCircle(canvas.getWidth()*6/8, canvas.getWidth()*5/8, canvas.getWidth()*228/1000, black);
canvas.drawCircle(canvas.getWidth()*7/8, canvas.getWidth()*5/8, canvas.getWidth()*103/1000, black);
arc0.set(canvas.getWidth()/2, canvas.getHeight()*-139/700, canvas.getWidth()*100/69, canvas.getHeight()*3/8);
arc1.set(canvas.getWidth()*-6/112, canvas.getHeight()*-80/100, canvas.getWidth()*195/100, canvas.getHeight()*72/192);
arc2.set(canvas.getWidth()*7/10, canvas.getHeight()*70/700, canvas.getWidth()*125/100, canvas.getHeight()*3/8);
arc3.set(canvas.getWidth()/2, canvas.getHeight()*3/8, canvas.getWidth()*100/69, canvas.getHeight()*91/96);
arc4.set(canvas.getWidth()*-8/112, canvas.getHeight()*3/8, canvas.getWidth()*195/100, canvas.getHeight()*150/100);
arc5.set(canvas.getWidth()*7/10, canvas.getHeight()*3/8, canvas.getWidth()*125/100, canvas.getHeight()*65/100);
圖表排隊上所有不同尺寸的屏幕模擬器我已經嘗試很好,所以會有人能告訴我,爲什麼不上排隊實際設備。謝謝
嘗試繪製一個簡單的形狀,如果它工作正常,硬編碼值必須存在問題,您是否介意發佈您的代碼和XML? –