• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps swipe not working for webview

My layout xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="#ffffff">


    <RelativeLayout android:id="@+id/l1"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:background="@drawable/blank_header" 
        android:layout_height="60dip">
        <Button android:id="@+id/home" android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical|center_horizontal"
            android:layout_width="wrap_content" android:layout_marginLeft="3dip"
            android:minHeight="20dip" android:layout_marginTop="0dip"
            android:minWidth="30dip" android:background="@drawable/btn_back">
        </Button>
        <LinearLayout android:layout_height="wrap_content"
            android:gravity="center" android:layout_width="fill_parent"
            android:layout_centerVertical="true" android:layout_marginRight="80dip"
            android:weightSum="1">
            <TextView android:layout_marginTop="5dip"
                android:layout_marginLeft="215dip" android:text="Epub Reader"
                android:marqueeRepeatLimit="marquee_forever" android:textSize="15dip"
                android:layout_gravity="left" android:layout_width="fill_parent"
                android:id="@+id/txt_chaptertitle" android:ellipsize="marquee"
                android:singleLine="false" android:layout_height="wrap_content"
                android:typeface="serif" android:textStyle="bold"
                android:layout_weight="0.18"></TextView>
        </LinearLayout>
    </RelativeLayout>
    <LinearLayout android:id="@+id/l2" android:layout_below="@id/l1"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:gravity="right" android:background="#ffffff"
        android:layout_height="wrap_content">


        <TextView android:textSize="15dip" android:id="@+id/txt_pageCount"
            android:layout_height="30dip" android:layout_width="70dip"
            android:layout_gravity="bottom|right|center_horizontal"
            android:paddingTop="5dip"></TextView>
        </LinearLayout>

        <LinearLayout
    android:layout_below="@id/l2"
        android:layout_above="@id/l3"        android:orientation="vertical" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="#ffffff">
            <WebView android:id="@+id/webView3" android:layout_height="fill_parent"
                android:layout_width="fill_parent">
            </WebView>
        </LinearLayout>

    <RelativeLayout android:layout_height="70dip" android:gravity="center" android:layout_width="fill_parent" android:id="@+id/l3" android:background="@drawable/footer" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true">
        <Button  android:layout_height="wrap_content" android:background="@drawable/btnnext" android:id="@+id/button4" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_alignParentRight="true"></Button >
        <Button  android:layout_height="wrap_content" android:background="@drawable/btnprevious" android:id="@+id/button3" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_alignParentLeft="true"></Button >
    
    </RelativeLayout>
</RelativeLayout>

I am having webview inside linear layout which in turn inside two relative layouts and the code to detect swipe is

Code:
public class Reader{

  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

 gestureDetector=new GestureDetector(new MyGestureDetector());

}

  class MyGestureDetector extends SimpleOnGestureListener implements OnGestureListener{
      @Override
      public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
          try {
              if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
                  return false;
              // right to left swipe
              if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {  // left swipe
                  
                  if(isLandscape()){
                      if(isnextButton){
                          forward();
                          
                      }} 
                      else{
                      if(isnextButtonPot){
                          forwardPotrait();
                      }
                      }
                        
                  
                  
                  
                  
              }  
              else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {  // right swipe
                 
                  
                     if(isLandscape()){
                      if(ispreviousButton){
                          previous();
                      }}
                      else{
                          
                          if(ispreviousButtonPot){
                              previousPotrait();
                          }
                          
                          
                      }
                  
                  
                  
              }
          } 
          
          
          catch (Exception e) {
              // nothing
          }
          return false;
      }
  }
      

}

My problem is when i swipe left to right or right to left
onfling method it is not getting called.I have pulled my hair for whole day so can any one help in this issue.

:)
 
Back
Top Bottom