In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "Android how to achieve water ripple effect", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "Android how to achieve water ripple effect" this article.
Effect picture
Attrs.xml
Custom attribute
RippleAnimationView.java
Manage water ripple attributes and animation statu
Public class RippleAnimationView extends RelativeLayout {private Paint paint; private int radius; private int strokeWidth; private int rippleColor; private AnimatorSet animatorSet; public RippleAnimationView (Context context) {this (context, null);} public RippleAnimationView (Context context, @ Nullable AttributeSet attrs) {this (context, attrs, 0);} public RippleAnimationView (Context context, @ Nullable AttributeSet attrs, int defStyleAttr) {super (context, attrs, defStyleAttr) Init (context, attrs);} private void init (Context context, AttributeSet attrs) {paint = new Paint (); paint.setAntiAlias (true); TypedArray array = context.obtainStyledAttributes (attrs, R.styleable.RippleAnimationView); / / Water ripple filling type int rippleType = array.getInt (R.styleable.RippleAnimationView_ripple_anim_type, 0); radius = array.getInteger (R.styleable.RippleAnimationView_radius, 54) StrokeWidth = array.getInteger (R.styleable.RippleAnimationView_stroeWidth, 2); rippleColor = array.getColor (R.styleable.RippleAnimationView_ripple_anim_color, ContextCompat.getColor (context, R.color.colorAccent)); array.recycle (); / / set brush lineweight paint.setStrokeWidth (UIUtils.getInstance (). GetWidth (strokeWidth)) If (rippleType = = 0) {paint.setStyle (Paint.Style.FILL);} else {paint.setStyle (Paint.Style.STROKE);} paint.setColor (rippleColor); LayoutParams params = new LayoutParams (UIUtils.getInstance (). GetWidth (radius + strokeWidth), UIUtils.getInstance (). GetWidth (radius + strokeWidth)) Params.addRule (CENTER_IN_PARENT, TRUE); / / scaling factor float maxScale = UIUtils.getInstance (). DisplayMetricsWidth / (2 * UIUtils.getInstance (). GetWidth (radius + strokeWidth)); / / delay time int rippleDuration = 3500; int singleDelay = rippleDuration / 4 / / time interval / / Animation set List animatorList = new ArrayList (); / / instantiate the water ripple view for (int I = 0bot I)
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.