5

Uygulamamda 'un NestedScrollView10'u kullanarak SwipeRefreshLayout'u kullanıyorum. SwipeRefreshLayout'dan istediğim şey, CollapsingToolbarLayout üzerinden kaydırmayı algılamaktır, ancak NestedScrollView üzerinden algılanması ve CollapsingToolbarLayout üzerinde hızlıca yok sayılmasıdır. İşte benim XML'im:Android Tasarım Kütüphanesi: SwipeRefreshLayout DaraltmaToolbarLayout üzerinden kaydırmayı algılamıyor

<?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> 

Bu tür bir şeyi kullanan var mı?

AppBarLayout docs belirtildiği üzere

cevap

5

, bu CoordinatorLayout

Bu görüş bir CoordinatorLayout içinde doğrudan çocuk olarak kullanılan büyük ölçüde bağlıdır doğrudan çocuk olmak zorundadır. Farklı bir ViewGroup içinde AppBarLayout kullanırsanız, işlevselliğinin çoğu çalışmayacak. SwipeToRefreshLayout NestedScrollView çok doğrudan çocuk olmak zorunda olduğu gibi, CollapsingToolbar ile birlikte çalışmak için dahil edilecek sahip olduğu

Böylece, emin değilim. İşte

SwipeRefreshLayout takmak ve appbar çökmemiş olduğu zaman aktif hale yardımcı another response olduğunu ama bana :(


DÜZENLEME için çalışmayan bir NestedScrollView, kullanmadığınız benim sorun için bir çözüm buldum: fo

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

Yani, bir solüsyon: kullandığım ListView, iç içe kaydırma olarak ayarlanmış yerine NestedScrollView içine koymak veya RecycleView ile değiştirilmesi gerekiyordu Sorununuz, NestedScrollView öğesini SwipeRefreshLayout içine sarmak olmalıdır.

İlgili konular