Sie zeichnen können Cursor blinkt auf diese Weise:
private long lastCursorChangeState = -1;
private boolean cursorVisible = true;
private Rect textBounds = new Rect();
@Override
protected void onDraw(Canvas canvas) {
if(isWriting){
if(System.currentTimeMillis() - lastCursorChangeState > 500) {
cursorVisible = !cursorVisible;
lastCursorChangeState = System.currentTimeMillis();
}
if(cursorVisible){
paint.getTextBounds(textToDraw, 0, textToDraw.length(), textBounds);
canvas.drawLine(textX+textBounds.right, textY-textSize, textX+textBounds.right, textY, paint);
}
postInvalidateDelayed(500);
}
}
warum Sie Stil verwenden Sie keine 'EditText'? –
@DimaRostopira, weil ich Text auf Position angeklickt hinzufügen möchte und ich Canvas für ein anderes Zeichenelement zusammen verwenden kann, funktioniert – hugerde