Android three gesture recognition for left and right swipe effects

Source: Internet
Author: User

Gesture recognition

Add Gesturedetector mgesturedetector in 1.onCreate;

Monitoring gesture Events

Mgesturedetector = new Gesturedetector (this, ongesturelistener);

2.//Implementing Processing Events

Ongesturelistener Ongesturelistener = new Ongesturelistener () {

Add a method that is not implemented

};

3. Overriding the Ontouch event

Handle touch events by gesture detection interface

public boolean ontouchevent (Motionevent event) {

Return Mgesturedetector.ontouchevent (event);

}

Left and right slide effect

1. Define the Viewflipper control in XML;

2. Overriding the Ontouchevent method for capturing touch events

View Code

3, Write Push_left_in.xml, Push_left_out.xml, Push_right_in.xml, push_right_out.xml file, used for sliding effect appears;

4, define Ongesturelistener in activity, rewrite onfling method, according to E1, E2 coordinate difference judge left and right sliding, and write the effect of sliding inside.

View Code

Project Download: Guideviewtest.rar

From: http://www.cnblogs.com/hanyonglu/archive/2012/02/13/2349827.html

Left and right slide guide effect

1, join Android-support-v4.jar, about the Android-support-v4.jar details, you can visit Google's official website: http://developer.android.com/sdk/ compatibility-library.html;

2, XML, complete the layout with framelayout, put in Viewpager and guide icon

View Code

3, the page layout is added to the View list, there are several layout pages there are a few dots picture, through the for loop set the layout of the dot picture;

View Code

4. Data adapter and page switching event listener

5. In the Guide page Change event Listener (Guidepagechangelistener), make sure that the dots below the picture also change when you switch the page

View Code

Project Download: Myandroidflip.rar

From: http://www.cnblogs.com/hanyonglu/archive/2012/04/07/2435589.html

Fade button left and right slide effect

1, XML, define Viewflipper control, add multiple page layout inside, also can use code Viewflipper AddView method;

2, Write Push_left_in.xml, Push_left_out.xml, Push_right_in.xml, push_right_out.xml documents;

3. Permission to join

<uses-permission android:name= "Android.permission.SYSTEM_ALERT_WINDOW"/>

4, in the activity, initialize the left and right hover button, create the left button, and set the listening events (replace the picture);

View Code

5, rewrite the Ontouchevent event, used to trigger the display and hide the hover button events (Motionevent.action_down and MOTIONEVENT.ACTION_UP);

6, using the thread, control the transparency of the hover button (alpha and invalidate)

Project Download: Mypagefliper.rar

From: http://www.cnblogs.com/hanyonglu/archive/2012/02/13/2350171.html

Category: Android technology

Android three left and right swipe gesture recognition

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.