2016-08-11 55 views
3

視差の動作をテストするために、サンプルScrollingActivity(SDKに含まれています)を使用しています。このサンプルでは、​​CoordinatorLayoutでNestedScrollViewを使用しています。画面の一番下から上にスクロールします。ツールバーでスクロールが停止します(スクロール速度が速い場合でも)。添付されたイメージでわかるように、展開されたAppBarLayoutを表示するには複数のスクロールが必要です。Android NestedScrollView CoordinatorLayoutのスムーススクロール

enter image description here

私は展開AppBarLayoutを参照するには、ユーザーのためのスムーズなスクロールが必要です。興味深いことに、NestedScrollViewの代わりにRecyclerViewを使用すると、この問題は発生しません。

ビルドツール23.0.3を使用しています。ここではレイアウトXMLは次のとおりです。

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="me.deepakmishra.swipetests.ScrollingActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/app_bar_height" 
     android:fitsSystemWindows="true" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

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

      <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/AppTheme.PopupOverlay" /> 

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

    <android.support.v4.widget.NestedScrollView 
     android:layout_gravity="fill_vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:context="me.deepakmishra.swipetests.ScrollingActivity" 
     tools:showIn="@layout/activity_scrolling"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/text_margin" 
     android:text="@string/large_text" /> 
    </android.support.v4.widget.NestedScrollView> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/fab_margin" 
     app:layout_anchor="@id/app_bar" 
     app:layout_anchorGravity="bottom|end" 
     app:srcCompat="@android:drawable/ic_dialog_email" /> 

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

答えて

0

私は同時に、速度と位置をカプセル化するイベントを取得することができませんでした、本質的にので、私は、この使用してCoordinatorLayoutを達成できませんでした。 CoordinatorLayoutは別々のコールバックで速度と位置を提供しており、それらを使用すると動きが鈍っています。

伝統的な方法でカスタムハンドラですべてのスクロール/飛行操作を追跡する視差効果を実装しました。

0

あなたのNestedScrollViewにandroid:fillViewport = "true"とandroid:layout_gravity = "fill_vertical"を追加します。これがあなたを助けることを願っています。

関連する問題