In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how Android uses circular exposure animation to skillfully hide or show View". In daily operation, I believe many people have doubts about how Android uses circular exposure animation to skillfully hide or show View problems. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "Android how to use circular exposure animation to skillfully hide or show View"! Next, please follow the editor to study!
1. Introduction
In the process of development, we often encounter situations where we need to show or hide the View view. If we add animation in the process of hiding or showing View, it can make the interaction more friendly and dynamic. This article will introduce how to use circular animation to hide or show View cleverly.
two。 A brief introduction to Circular Disclosure Animation
Circle exposure animation is a kind of animation, which is provided by the ViewAnimationUtils class. Call the ViewAnimationUtils.createCircularReveal () method to create a circle exposure animation. Using this animation requires an API level of 21 or above. The parameters of the createCircularReveal () method are as follows:
/ / view: view using circle animation / / centerX: the X coordinate of the center of the crop circle, this center refers to the Y coordinate relative to the view itself / / centerY: the center of the crop circle, this center refers to the starting radius of the circle relative to the view itself / / startRadius: the starting radius of the circle / / endRadius: the end radius of the circle public static Animator createCircularReveal (View view,int centerX, int centerY, float startRadius, float endRadius) 3. Use circular expose animation to hide or show View3.1 simple layout
The simple layout is as follows:
3.2Hidden View with circular expose animation
First, calculate the X and Y coordinates of View relative to its center point, then call the Math.hypot () method to calculate the radius of the circle, then call ViewAnimationUtils.createCircularReveal (imageView, ivXCenter, ivYCenter, circleRadius, 0f) to create a circle exposure animation, increase the Listener of animation execution, call imageView.setVisibility (View.GONE) after the animation is finished, and finally start the animation. Examples are as follows:
If (Build.VERSION.SDK_INT > = Build.VERSION_CODES.LOLLIPOP) {int width = imageView.getWidth (); int height = imageView.getHeight (); int ivXCenter = width/2; int ivYCenter = height/2; float circleRadius = (float) Math.hypot (ivXCenter, ivYCenter); Animator circularReveal = ViewAnimationUtils.createCircularReveal (imageView, ivXCenter, ivYCenter, circleRadius, 0f) CircularReveal.addListener (new AnimatorListenerAdapter () {@ Override public void onAnimationEnd (Animator animation) {super.onAnimationEnd (animation); imageView.setVisibility (View.GONE); isVisible = false;}}); circularReveal.start ();} else {imageView.setVisibility (View.GONE); isVisible = false;} 3.3 use circular exposure animation to display View
Use circle exposure animation to display View. First, calculate the X and Y coordinates of View relative to its center point, then calculate the radius of the circle, and then create a circle exposure animation, where the starting radius is 0f and the end radius is the radius of the circle. Call imageView.setVisibility (View.VISIBLE), and finally start the animation. Examples are as follows:
If (Build.VERSION.SDK_INT > = Build.VERSION_CODES.LOLLIPOP) {int width = imageView.getWidth (); int height = imageView.getHeight (); int ivXCenter = width/2; int ivYCenter = height/2; float circleRadius = (float) Math.hypot (ivXCenter, ivYCenter); Animator circularReveal = ViewAnimationUtils.createCircularReveal (imageView, ivXCenter, ivYCenter, 0f, circleRadius); imageView.setVisibility (View.VISIBLE); isVisible = true; circularReveal.start () } else {imageView.setVisibility (View.VISIBLE); isVisible = true;} at this point, the study on "how Android uses circular reveal animation to skillfully hide or show View" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.