5

In meiner App verwende ich CollapsingToolbarLayout folgende NestedScrollView innerhalb SwipeRefreshLayout. Was ich von SwipeRefreshLayout will, ist das Wischen über von CollapsingToolbarLayout, aber seine Erkennung über NestedScrollView und ignorieren Streichen auf CollapsingToolbarLayout. Hier ist mein XML:Android Design-Bibliothek: SwipeRefreshLayout nicht wischen über CollapsingToolbarLayout

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/rootLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.v4.widget.SwipeRefreshLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/swipe" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

      <android.support.design.widget.AppBarLayout 
       android:id="@+id/appBarLayout" 
       android:layout_width="match_parent" 
       android:layout_height="256dp" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

       <android.support.design.widget.CollapsingToolbarLayout 
        android:id="@+id/collapsingToolbarLayout" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        app:contentScrim="?attr/colorPrimary" 
        app:expandedTitleMarginStart="@dimen/expanded_toolbar_title_margin_start" 
        app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

        <ImageView 
         android:id="@+id/profilePic" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:scaleType="centerCrop" 
         android:src="@drawable/ic_split_big_profile" 
         app:layout_collapseMode="parallax" 
         app:layout_collapseParallaxMultiplier="0.7" /> 

        <include 
         android:id="@+id/toolbar_layout" 
         layout="@layout/toolbar" 
         android:layout_width="match_parent" 
         android:layout_height="?attr/actionBarSize" 
         app:layout_collapseMode="pin" 
         app:layout_scrollFlags="scroll|enterAlways" /> 

       </android.support.design.widget.CollapsingToolbarLayout> 
      </android.support.design.widget.AppBarLayout> 

      <android.support.v4.widget.NestedScrollView 
       android:id="@+id/transactions_scroll" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="500dp"> 
       </RelativeLayout> 
      </android.support.v4.widget.NestedScrollView> 

      <android.support.design.widget.FloatingActionButton 
       android:id="@+id/add_button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom|right" 
       android:layout_marginBottom="@dimen/fab_margin_bottom" 
       android:layout_marginRight="@dimen/fab_margin_right" 
       android:onClick="addTxn" 
       android:src="@drawable/ic_action_add_transaction_light" 
       app:elevation="6dp" 
       app:fabSize="normal" /> 

     </android.support.v4.widget.SwipeRefreshLayout> 
    </android.support.design.widget.CoordinatorLayout> 
</RelativeLayout> 

Hat jemand diese Art von etwas verwendet?

Antwort

5

Wie in AppBarLayout docs erwähnt, hat es direkt untergeordnet CoordinatorLayout

Diese Ansicht auf stark sein, hängt in einem CoordinatorLayout als direktes Kind verwendet wird. Wenn Sie AppBarLayout in einer anderen ViewGroup verwenden, funktionieren die meisten Funktionen nicht.

So, ich bin nicht sicher, wo die SwipeToRefreshLayout eingeschlossen werden muss, gemeinsam mit dem CollapsingToolbar, wie NestedScrollView zu direkt Kind sein muss.

Hier ist another response, die die SwipeRefreshLayout befestigen hilft und aktivieren Sie es nur, wenn die AppBar nicht kollabierten ist, aber sie sind nicht mit einer NestedScrollView, die nicht für mich funktioniert :(


EDIT ich fand eine Lösung für mein Problem: Das Listview habe ich, wie verschachtelte Scroll eingestellt werden musste, anstatt sie setzen in einem NestedScrollView oder mit RecycleView ersetzt:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
    listView.setNestedScrollingEnabled(true); 
} 

so eine Lösung fo Ihr Problem sollte darin bestehen, das NestedScrollView in das SwipeRefreshLayout zu schreiben.