3

시차 동작을 테스트하기 위해 샘플 ScrollingActivity (SDK에 포함)를 사용하고 있습니다. 이 샘플에서는 CoordinatorLayout에서 NestedScrollView를 사용합니다. 화면의 맨 아래에서 위로 스크롤하면; 툴바에서 스크롤이 멈 춥니 다 (스크롤이 고속 일지라도). 첨부 된 이미지에서 볼 수 있듯이 확장 된 AppBarLayout을 표시하려면 여러 개의 스크롤이 필요합니다. Android NestedScrollView CoordinatorLayout의 부드러운 스크롤

enter image description here

나는 확장 AppBarLayout을 볼 수있는 사용자를위한 부드러운 스크롤이 필요합니다. 흥미롭게도 NestedScrollView 대신 RecyclerView를 사용하면이 문제가 발생하지 않습니다.

저는 빌드 도구 23.0.3을 사용하고 있습니다.

<?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을 달성 할 수 다음은 레이아웃 XML입니다. CoordinatorLayout은 별도의 콜백에서 속도와 위치를 제공하며,이를 사용하면 더듬 거리는 움직임이 발생합니다.

모든 스크롤/플링 작업을 추적하기 위해 커스텀 핸들러로 전통적인 방식으로 시차 효과를 구현했습니다.

0

android : layoutView = "true"android : layout_gravity = "fill_vertical"을 NestedScrollView에 추가하십시오. 희망이 당신을 도울 것입니다.