1

I want to draw a circle with Canvas. As the code below, i can draw a circle on the view but i wonder that; how to make an animated circle as radius increases slowly and color is going to lighter (like a drop wave on water). like :

enter image description here

Can anyone help? Thanks.

Draws simple circle with canvas :

protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
        mPaint.setColor(Tool.colors[6]);
        canvas.drawCircle(coorX(), coorY(), radius, mPaint);
}

Shows touches on the screen as in settings->developer options->show touches : This code uses system settings. So i only get animated circle which is defined already and cannot be change (radius,color, etc.).

private final String SHOW_TOUCHES_SETTING = "show_touches";
private boolean getSystemSetting(){
    return Settings.System.getInt(getContentResolver(), SHOW_TOUCHES_SETTING, 0) == 1;
}  
private void setSystemSetting(boolean paramBoolean){
    if (getSystemSetting() == paramBoolean) {
      return;
    }
    for (;;){
        try{
            ContentResolver localContentResolver = getContentResolver();
            if (paramBoolean){
              Settings.System.putInt(localContentResolver, SHOW_TOUCHES_SETTING, 1);
              return;
            }
        }
        finally {}
    }
}

protected void onCreate(Bundle paramBundle){
    super.onCreate(paramBundle);
    setContentView(R.layout.activity_main);
    this.setSystemSetting(paramAnonymousBoolean);
}
reigeki
  • 391
  • 1
  • 5
  • 19
  • Try my old project with animation on canvas. It has example what you needed: https://github.com/nfirex/CanvasAnimationView – nfirex Jun 06 '14 at 16:18
  • thanks for reply, I've uploaded a screen shot. I want to draw like these circles. How can i do this? – reigeki Jun 06 '14 at 16:29
  • I don't not clearly understand what you want:) But I added CirclesCanvasAnimation in examples. Is that example can help you? You can make your own implementation and just take mechanism for working with draw-method from my project. And modify Circles for draw as you wish. – nfirex Jun 06 '14 at 18:28
  • If you want glow effect for circle, you need to add in Paint BlurMaskFilter in code. Like this: paint.setMaskFilter(new BlurMaskFilter(, Blur.INNER)) – nfirex Jun 06 '14 at 18:33
  • Have you made any progress implementing this ? – limon Aug 26 '14 at 09:53
  • Checkout this one, you should be able to adapt it to your needs: http://stackoverflow.com/questions/18616035/how-to-animate-a-path-on-canvas-android – Ostkontentitan Sep 18 '14 at 15:45

0 Answers0