【发布时间】:2014-11-27 12:16:40
【问题描述】:
我现在可以在运动视图上的画布上绘制文本,问题是当我绘制文本并在同一画布上进行下一次绘制时,我的绘制文本正在消失我的意思是屏幕正在重绘,因为我想要的无效保留我之前的绘图并在同一个画布上进行新的绘图我将如何做到这一点?
@Override
protected void onDraw(Canvas canvas) {
Paint hint = new Paint();
path = new Path();
mTextPaths = new ArrayList<Path>();
Log.v("getting mtextpaths", mTextPaths.toString());
int m;
if (strgettile != null) {
for (m = 0; m < strgettile.length(); m++) {
System.out.println(strgettile.charAt(m));
char convertst = strgettile.charAt(m);
characterToString = Character.toString(convertst);
// canvas.drawText(characterToString, x, y, hint);
// canvas.drawText(characterToString, m
// * width + x, m * height + y, foreground); //its working in
// cross
// canvas.drawText(characterToString, x, m * height + y,
// foreground); //its working for vertical
// canvas.drawText(characterToString, m
// * width + x, y, foreground); //its working in horizontal
// setSelectedTile(tile);
if (getorientation.equalsIgnoreCase("Horizontal")) {
canvas.drawText(characterToString, m * width + positionX,
positionY, foreground); // for motion event
hint.setColor(Color.BLACK);
hint.setTextSize(45);
foreground.getTextPath(characterToString, 0,
characterToString.length(), positionX * 2 / 3,
positionY - 4, path);
} else {
canvas.drawText(characterToString, positionX, m * height
+ positionY, foreground);
hint.setColor(Color.BLACK);
hint.setTextSize(45);
foreground.getTextPath(characterToString, 0,
characterToString.length(), positionX * 2 / 3,
positionY - 4, path);
}
}
}
public void setSelectedTile(String tile, String strorientations) {
// TODO Auto-generated method stub
Log.v("getting string in puzzle view ", tile);
strgettile = tile;
getorientation = strorientations;
mTextPaths.add(path);
invalidate();
}
【问题讨论】:
标签: android text android-canvas draw