title: Animation On Custom View Android
body: <p>I have created a custom view shows below
  <a href="https://i.stack.imgur.com/MlafO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MlafO.png" alt="Custom View"></a></p>
  
  <p>I want to add an animation to the element when the user clicks on each color the color should pop down and pop up </p>
  
  <p>some part of custom view code </p>
  
  <pre><code>override fun onDraw(canvas: Canvas?) {
      super.onDraw(canvas)
  
      // draw elements
      for(i in 0..5){
          drawElementOrCursor(canvas,cXArray[i]!!,cYArray[i]!!,elementRadius!!,colorArray[i]!!)
      }
  
      // draw cursor
      drawElementOrCursor(
          canvas,cXArray[0]!!,
          (elementCursorSize!!/2)+8+elementSize!!,
          elementCursorRadius!!,
          colorArray[0]!!)
  
  }
  
  private fun drawElementOrCursor(canvas: Canvas?,cX: Int,cY: Int,radius: Float,color: Int){
      paint.color = color
      paint.style = Paint.Style.FILL
  
      canvas?.drawCircle(cX.toFloat(),cY.toFloat(),radius,paint)
  }
  </code></pre>