2016-08-01 18 views
0

Wie kann ich GestureOverlayView in meinem CoordinatorLayout in NestedScrollView setzen? weil mein Problem ist, dass, wenn ich in gestureOverlay scrollen, gerade Seite und die Geste ist inusable.GesureOverlayView in CoordinatorLayout scrollen und NestedScrollView

Mein activity.xml

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:id="@+id/scrollViewreceipt" 
    tools:context=".activities.activity"> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/activityRecicler" 
       android:layout_width="match_parent" 
       android:layout_height="300dp" 
       android:layout_marginTop="15dp" 
       app:stackFromEnd="true" /> 
      <android.gesture.GestureOverlayView 
       android:id="@+id/signaturePad" 
       android:layout_width="match_parent" 
       android:layout_height="80dp" 
       android:layout_weight="5" 
       android:background="#d3d3d3" 
       android:eventsInterceptionEnabled="true" 
       android:fadeEnabled="false" 
       android:gestureColor="#333" 
       android:gestureStrokeLengthThreshold="0.1" 
       android:gestureStrokeType="multiple" 
       android:fadeOffset="5000" 
       android:orientation="vertical"> 
      </android.gesture.GestureOverlayView> 
      <Button android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:onClick="testImage" 
       android:text="testami" 
      /> 
     </LinearLayout> 
     </android.support.v4.widget.NestedScrollView> 
     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="56dp" 
      android:layout_height="56dp" 
      android:layout_gravity="bottom|end" 
      android:layout_margin="@dimen/fab_margin" 
      app:backgroundTint="#b2d33f" 
      android:src="@drawable/ic_save_black_36dp" 
      android:onClick="saveReceipt" /> 
</android.support.design.widget.CoordinatorLayout> 

Wenn ich in GestureOverlayView die gesamte Seite blättern in vertikalen ziehen und hält Unentschieden.

Antwort

0

Ich habe mit einer Klasse aufgelöst, die NestedScrollView erweitert:

public class CustomView extends android.support.v4.widget.NestedScrollView { 
    private boolean enableScrolling = true; 

    public boolean isEnableScrolling() { 
     return enableScrolling; 
    } 

    public void setEnableScrolling(boolean enableScrolling) { 
     this.enableScrolling = enableScrolling; 
    } 

    public CustomScrollView(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    public CustomScrollView(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public CustomScrollView(Context context) { 
     super(context); 
    } 

    @Override 
    public boolean onInterceptTouchEvent(MotionEvent ev) { 
     Log.e("enabled", String.valueOf(isEnableScrolling())); 
     if (isEnableScrolling()) { 
      return super.onInterceptTouchEvent(ev); 
     } else { 
      return false; 
     } 
    } 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) { 
     if (isEnableScrolling()) { 
      return super.onTouchEvent(ev); 
     } else { 
      return false; 
     } 
    } 
} 

und die Aktivität implementiert GestureOverlayView.OnGestureListener:

@Override 
public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) { 
    myScrollView.setEnableScrolling(false); 
} 

@Override 
public void onGesture(GestureOverlayView overlay, MotionEvent event) { 
} 

@Override 
public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) { 
    myScrollView.setEnableScrolling(true); 
} 

Und in meinem XML änderte ich android.support.v4.widget.NestedScrollView mit CustomView.