0

enter image description here沒有崩潰

正如你可以在上面看到,當我從「觀葉植物」滾動可摺疊工具欄時,CollapsibleToolbar崩潰的預期,但是當我從任何產品形象,AppBarLayout下面的頁面滾動拖動。爲什麼會發生這種情況以及如何解決此問題?我試着將VerticalRecyclerView.setNestedScrolling設置爲false,但沒有奏效。

如下片段的 enter image description here

結構位於內ViewPager我的主頁佈局的結構

enter image description here

主頁的佈局

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    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.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways" 
      app:titleEnabled="false"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar_productdetail" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/recyclerview_home_categoryfooter" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="?attr/actionBarSize" 
       app:layout_collapseMode="parallax" 
       app:layout_collapseParallaxMultiplier="1.0"/> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/search_background_list" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <ProgressBar 
      android:id="@+id/progressbar_home_loading" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/> 

     <TextView 
      android:id="@+id/textview_home_status" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/search_background_list" 
      android:gravity="center" 
      android:text="No Results Found" 
      android:visibility="invisible"/> 

     <experttag.nurserylive.util.ui.widget.CustomViewPager 
      android:id="@+id/viewpager_home" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 

     <fragment 
      android:id="@+id/fragment_search" 
      android:name="experttag.nurserylive.fragment.SearchFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
    </FrameLayout> 
</android.support.design.widget.CoordinatorLayout> 

佈局片段內ViewPager是如下

@ ID內的內水平面RecyclerView項目
<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerview_productoverview" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/windowBackground"/> 

佈局/ recyclerview_productoverview

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    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="wrap_content"> 

    <android.support.constraint.ConstraintLayout 
     android:id="@+id/layout_section_header" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:background="#ccc" 
     android:paddingBottom="10dp" 
     android:paddingTop="10dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent"> 

     <experttag.nurserylive.util.ui.widget.WhitneySemiBoldTextView 
      android:id="@+id/textview_item_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="0dp" 
      android:layout_marginEnd="16dp" 
      android:layout_marginLeft="0dp" 
      android:layout_marginRight="0dp" 
      android:layout_marginStart="16dp" 
      android:layout_marginTop="0dp" 
      android:text="TOP FEATURED" 
      android:textColor="#000" 
      android:textSize="16sp" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toTopOf="parent"/> 

     <ImageView 
      android:id="@+id/imageview_item_viewall" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:background="?attr/selectableItemBackgroundBorderless" 
      android:clickable="true" 
      android:paddingLeft="16dp" 
      android:paddingRight="16dp" 
      android:tint="#000" 
      app:layout_constraintRight_toRightOf="parent" 
      app:srcCompat="@drawable/ic_arrow_forward_black_24dp"/> 
    </android.support.constraint.ConstraintLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerview_item_section" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/layout_section_header"/> 

</android.support.constraint.ConstraintLayout> 
+0

嘗試移除layout_scrollflags屬性中的enteralways標誌 – dustblue

回答

0

setNestedScrollingEnabled(假的)解決了這個問題對我來說。