I've added the drag functionality to a component using ViewDragHelper and I'm trying to add a fade animation to the component so that when the user touches the screen and drag it, it changes the component's alpha using an animation. The problem is that the animation waits for the user's interaction to stop and then it applies the animation so that during the component transition, you can't see the alpha animation,
override fun clampViewPositionVertical(child: View, top: Int, dy: Int): Int {
if(top < verticalRange)
return verticalRange
backgroundView.animate().alpha((backgroundView.alpha - 0.05).toFloat()).duration = 10
return top
}
The on touch Event:
override fun onTouchEvent(event: MotionEvent): Boolean {
return if (isDragEnabled && (isControlScreenLayoutTarget(event) || isMoving)) {
viewDragHelper.processTouchEvent(event)
true
} else {
super.onTouchEvent(event)
}
}