Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the springback effect of sliding and loosening the background image by Android

Shulou Source: shulou.com Published: 2022-05-31 21:09:39 10月04日 Update

This article mainly explains "Android how to achieve the background image sliding larger release rebound effect", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Android how to achieve the background image sliding larger release rebound effect" bar!

Original drawing

After magnification

1. Custom view inherits ScrollView implementation effect

Public class HeadZoomScrollView extends ScrollView {whether the position where the private View mZoomView; private int mZoomViewWidth; private int mZoomViewHeight; private float firstPosition;// record was pressed for the first time is private boolean isScrolling;// scaling private float mScrollRate = 0.3f super / scaling factor. The larger the zoom factor is, the greater the change is. The larger the zoom factor is, the slower the callback is public HeadZoomScrollView (Context context) {super (context). } public HeadZoomScrollView (Context context, AttributeSet attrs) {super (context, attrs);} public HeadZoomScrollView (Context context, AttributeSet attrs, int defStyleAttr) {super (context, attrs, defStyleAttr);} public void setmZoomView (View mZoomView) {this.mZoomView = mZoomView;} public void setmScrollRate (float mScrollRate) {this.mScrollRate = mScrollRate;} public void setmReplyRate (float mReplyRate) {this.mReplyRate = mReplyRate } @ Override protected void onFinishInflate () {super.onFinishInflate (); init ();} private void init () {setOverScrollMode (OVER_SCROLL_NEVER); if (getChildAt (0)! = null) {ViewGroup vg = (ViewGroup) getChildAt (0); if (vg.getChildAt (0)! = null) {mZoomView = vg.getChildAt (0) @ Override public boolean onTouchEvent (MotionEvent ev) {if (mZoomViewWidth)

Tags: Effects background location coefficients learning content layout processing size events animation original pictures pictures that is ideas situations fingers controls articles are in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology Xiaomi NVidia Shulou Information