2

您好我正在經歷一種滯後時NestedScrollView滾動和觀察這個滾動滯後,直到視圖崩潰一旦視圖摺疊滾動工作正常。NestedScrollView滾動延遲,直到CollapsingToolbarLayout視圖不折疊

有沒有解決方案不是這個。

以下是XML代碼

<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:fitsSystemWindows="true"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginEnd="64dp" 
     app:expandedTitleMarginStart="48dp" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <com.antonioleiva.materializeyourapp.widgets.SquareImageView 
      android:id="@+id/image" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      app:layout_collapseMode="parallax" /> 

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

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

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

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

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="24dp" 
      app:cardElevation="@dimen/spacing_medium" 
      app:cardUseCompatPadding="true"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/title" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="@dimen/spacing_large" 
        android:layout_marginRight="@dimen/spacing_large" 
        android:layout_marginTop="@dimen/spacing_large" 
        android:textAppearance="@style/TextAppearance.AppCompat.Headline" /> 

       <TextView 
        android:id="@+id/description" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_margin="@dimen/spacing_large" 
        android:text="@string/lorem_ipsum" 
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> 

      </LinearLayout> 

     </android.support.v7.widget.CardView> 

    </FrameLayout> 

</android.support.v4.widget.NestedScrollView> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    style="@style/FabStyle" 
    app:layout_anchor="@id/app_bar_layout" 
    app:layout_anchorGravity="bottom|right|end" /> 

</android.support.design.widget.CoordinatorLayout> 

回答

1

看來你需要使用this庫。我認爲它會解決你的問題。

爲了完整起見,我張貼從上述文庫例如採取的代碼起見

<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.v7.widget.RecyclerView 
    android:id="@android:id/list" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

    <me.henrytao.smoothappbarlayout.SmoothAppBarLayout 
    android:id="@+id/smooth_app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/app_bar_height"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     app:layout_collapseMode="pin" 
     app:navigationIcon="@drawable/ic_toolbar_arrow_back" 
     style="@style/AppStyle.MdToolbar" /> 

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

    </me.henrytao.smoothappbarlayout.SmoothAppBarLayout> 

</android.support.design.widget.CoordinatorLayout> 
相關問題