0

나는이 라이브러리 조금 수정하려고 : https://github.com/Shinelw/ColorArcProgressBarCircle ProgressBar와 함께 비트 맵을 회전하는 방법은 무엇입니까?

그리고 이것은 내가 자주색 원 표시없이, 지금까지 를 무슨 짓을했는지 있습니다 : arc progress bar

내 질문은 : 내가 애니메이션을 할 수있는 방법 진행과 함께 보라색 동그라미 (이미지에 표시된대로)? onDraw는 방법에서보기를 확장

내부 ColorArcProgressBar 클래스는이 진행 그리는 방법입니다 : canvas.drawArc(bgRect, startAngle, currentAngle, false, progressPaint);

및 애니메이션 나가의 시작 부분에 보라색 bitmat의 위치를 ​​관리

private void setAnimation(float last, float current, int length) { 
    progressAnimator = ValueAnimator.ofFloat(last, current); 
    progressAnimator.setDuration(length); 
    progressAnimator.setTarget(currentAngle); 
    progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 

     @Override 
     public void onAnimationUpdate(ValueAnimator animation) { 
      currentAngle = (float) animation.getAnimatedValue(); 
      curValues = currentAngle/k; 
     } 
    }); 
    progressAnimator.start(); 

} 

입니다 이 진행 상황은 다음과 같습니다.

canvas.drawBitmap(mIcon,bgRect.left+mIcon.getWidth()/2 +30, bgRect.bottom - 40 +mIcon.getHeight()/2 , null); 

이제 진행 상황과 같은 호를 따라 어떻게 애니메이션을 적용 할 수 있습니까?

그것이 가까이 옳지 않아 경우

답변

0

// since currentAngle is a "sweep" angle, the 
    // final angle should be current + start 
    float thetaD = startAngle + currentAngle; 
    if (thetaD > 360F) { 
     thetaD -= 360F; 
    } 

    // convert degrees to radians 
    float theta = (float) Math.toRadians(thetaD); 

    // polar to Cartesian coordinates 
    float x = (float) (Math.cos(theta) * bgRect.width()/2) + bgRect.centerX(); 
    float y = (float) (Math.sin(theta) * bgRect.height()/2) + bgRect.centerY(); 

    canvas.drawBitmap(mIcon, x - mIcon.getWidth()/2, y - mIcon.getHeight()/2 , null); 

그것은 비트 맵이 원형입니다 도움 ...이 밖으로 시도하지 않았다, 그래서 우리는 회전하지 않았다 ...

+0

그것은 완벽하게 작동합니다! 정말 고맙습니다! – JuLes

+0

나는 몇 가지 시도를했지만, 이제 나는 우리가 비뚤어진 죄와 죄를 지어야한다는 사실을 잊어 버렸고, 나의 x와 y는 동일하지만 가계와 죄가 없었다. – JuLes