Animation in Android

 1-circular reveal animation on a view :



private fun circulerReveal(){

try { // Calculate the center coordinates of the view int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; // Calculate the distances to the edges of the view int dx = Math.max(cx, myView.getWidth() - cx); int dy = Math.max(cy, myView.getHeight() - cy); // Calculate the final radius of the circular reveal float finalRadius = (float) Math.hypot(dx, dy); // Create a circular reveal animator for the view Animator animator = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); // Set the animation interpolator (how the animation accelerates or decelerates) animator.setInterpolator(new AccelerateDecelerateInterpolator()); // Set the duration of the animation in milliseconds animator.setDuration(1500); // Start the animation animator.start(); } catch (Exception e) { // Handle any exceptions that might occur during the animation setup }
}

Rajeshbhatt12

My name is Rajesh Bhatt. I am working as a senior android developer . I have created this blog for kotlin ,java and Android Development interview questions etc..

Previous Post Next Post