내 코드 나 또한 글고처럼 커서를 여기에 추가 할 여기캔버스에 drawtext에 커서를 추가 할 수 있습니까?
textPaint.setStyle(Paint.Style.FILL);
textPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawText(substring, textX, y, this.textPaint);
입니다
내 코드 나 또한 글고처럼 커서를 여기에 추가 할 여기캔버스에 drawtext에 커서를 추가 할 수 있습니까?
textPaint.setStyle(Paint.Style.FILL);
textPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawText(substring, textX, y, this.textPaint);
입니다
아니, 지금까지의 텍스트가 비트 맵의 일부이며 텍스트로 해석되지 때문에, 그것은 가능하지 알고 텍스트 마커 인터페이스에 의해.
내가 다른 해결책 제안다음을 호출하여
이
<FrameLayout>
<Canvas />
<TextView />
<!-- More textviews -->
</FrameLayout>
당신은 FrameLayout이 내부의 텍스트 뷰를 배치 할 수 있습니다 그런 캡슐화 된 레이아웃 구조를 (레이아웃 만 simplyfied!) 사용을 기능 세트 X 또는 세트 Y. 텍스트 뷰는 캔버스 뒤에 정의되어있는 한 항상 캔버스의 맨 위에 그려집니다. 또한 당신은 기능을 setVisibility를 호출하여 코드에 의해이/볼 보이지 않는 수 그 외에도
, 동적 코드를 사용하여 대신의 레이아웃 XML의 정적 텍스트 뷰를 정의하는 FrameLayout이 더 Textviews을 추가 할 수 있습니다
: 당신은 왜`EditText` 스타일을 사용하지 않는
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);
}
}
를? –
@DimaRostopira 클릭 한 위치에 텍스트를 추가하고 함께 다른 드로잉 요소에 캔버스를 사용해야하므로 – hugerde