【发布时间】:2012-11-18 03:57:30
【问题描述】:
当我点击按钮时,调用drawDigit(),puzzleview只是Activity中的一个LinearLayout
protected void drawDigit(Canvas canvas, int digit) {
// TODO Auto-generated method stub
if(num < diff){
int x = tiles.get(num).getScrollX(); // get the X coordinate of ImageView,it's 0
int y = tiles.get(num).getScrollY(); // get the Y coordinate of ImageView,it's 0
float height = tiles.get(num).getHeight(); // height is 0
float width = tiles.get(num).getWidth(); // width is 0
background.setTextSize(height * 0.75f);
background.setStyle(Style.FILL);
background.setTextScaleX(width/height);
background.setTextAlign(Paint.Align.CENTER);
canvas.drawText(digit + "", x, y, background);
//num++;
}
}
如何将布局中的ImageView 分配给图块,然后获取坐标和大小?
【问题讨论】:
-
stackoverflow.com/questions/4933612/…。看看链接中的答案,应该对你有帮助。
-
num是什么?diff是什么?tiles是什么?
标签: android android-layout android-canvas