Android Shielded ScrollView Swipe operation

Source: Internet
Author: User

Shielded ScrollView sliding operations, such as the following, will use the Viewconfiguration class, this class can get to whether the user is a sliding operation of the critical value.

The code is as follows:

Package Com.xx.uikit.view;import Android.content.context;import Android.util.attributeset;import Android.view.motionevent;import Android.view.viewconfiguration;import android.widget.scrollview;/** * Copyright© Edaixi. All rights Reserved. * author:wei_spring * DATE:16/8/19 * Email: * Function: Custom ScrollView, block sliding events, resolve sliding conflicts with recycler */public class RECYCLERSCR    Ollview extends ScrollView {private int downY;    private int mtouchslop;        Public Recyclerscrollview (Context context) {super (context);    Mtouchslop = Viewconfiguration.get (context). Getscaledtouchslop ();        } public Recyclerscrollview (context context, AttributeSet Attrs) {Super (context, attrs);    Mtouchslop = Viewconfiguration.get (context). Getscaledtouchslop (); } public Recyclerscrollview (context context, AttributeSet attrs, int defstyleattr) {Super (context, Attrs, defst        YLEATTR);    Mtouchslop = Viewconfiguration.get (context). Getscaledtouchslop (); } @Override Public Boolean onintercepttouchevent (Motionevent e) {int action = e.getaction ();                Switch (action) {Case MotionEvent.ACTION_DOWN:downY = (int) E.getrawy ();            Break                Case MotionEvent.ACTION_MOVE:int Movey = (int) E.getrawy ();                if (Math.Abs (movey-downy) > Mtouchslop) {return true;    }} return Super.onintercepttouchevent (e); }}

Android Shielded ScrollView Swipe operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.