2017-04-08 22 views
0

나는 화살을 그리려고하고 있지만 정말 이상한 결과를 얻는다. This is how it looks like이 문제는 상당히 명확합니다. 중복되는 부분입니다. onDraw는 방법 내에서Android - 경로로 화살표를 올바르게 그리는 방법?

int radius = 100; //Radius of blue circle to the right 
Path leftArrow = new Path(); 
Paint leftArrowPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 

leftArrowPaint.setStyle(Paint.Style.STROKE); 
leftArrowPaint.setColor(ContextCompat.getColor(getContext(), R.color.buttonText)); 
leftArrowPaint.setAlpha(80); 
leftArrowPaint.setStrokeWidth(8); 

:

//Start point 
leftArrow.moveTo(touchX-(radius+5), (int)touchY); 
//Line to left 
leftArrow.lineTo(touchX-(radius+60), (int)touchY); 
//Line up 
leftArrow.lineTo(touchX-(radius+30), (int)touchY-30); 
//Move back to the middle 
leftArrow.moveTo(touchX-(radius+60), (int)touchY); 
//Line down 
leftArrow.lineTo(touchX-(radius+30), (int)touchY+30); 
canvas.drawPath(leftArrow, leftArrowPaint); 
leftArrow.reset(); 

답변

1

좋아, 내가 너무 늦게 당신을 위해 알고,하지만 난 어쨌든 거 대답을 해요 경우 누군가가 같은 문제를 가로 질러 온다.

페인트 결합 속성을 지정해야합니다. https://developer.android.com/reference/android/graphics/Paint.Join.html

leftArrowPaint.setStrokeJoin(Paint.Join.BEVEL); 

당신은 또한 당신을 위해 더 나은 모습에 따라, Paint.Join.ROUND를 사용할 수 있습니다.