Android swipe up or down to show the underlying layout

Source: Internet
Author: User

Reprint Blog Address: http://www.cnblogs.com/flyme2012/p/4106308.html

Idle nothing to do a little thing. Android is sliding up or down, showing the underlying layout. Can do similar to the QQ message list deletion function.

Look at the effect:
The realization of the basic principle: the previous period of time to learn the Viewdraghelper class, probably through this class to control the sliding of the left and right, convenient many Ah, is also very simple code, you can refer to my previous about Viewdraghelper blog post, The main thing to do here is to pass on the touch event, which needs to pass the touch event to the underlying layout. @Override Public boolean dispatchtouchevent (motionevent ev) { switch (ev.getaction ()) { Case motionevent. Action_down: StartX = (int) ev.getx (); starty = (int) ev.gety (); if (bottomstate = = Defult_bottom | | Bottomstate = = defult_top) { bottomview.dispatchtouchevent (EV);             } topview.dispatchtouchevent (EV); Break ; Case motionevent. ACTION_UP: int moveX2 = (int) ev.getx (); int moveY2 = (int) ev.gety (); if (Math. ABS ((moveY2- starty)) < 8) { if  (Getstatusstate ()  == status.open &&  (bottomstate == defult_bottom | |  bottomstate = =  Defult_top bottomview.dispatchtouchevent (EV); }Else if (getstatusstate () = = Status. Close) { topview.dispatchtouchevent (EV);                 }}else { ontouchevent (EV); return true;             }Break ;         } return super.dispatchtouchevent (EV);     }  SOURCE Address: Http://pan.baidu.com/s/1c0q2VRy My github address: https://github.com/flyme2012 My blog address: http://www.cnblogs.com/flyme2012/

Android swipe up or down to show the underlying layout

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.