2017-11-07 16 views
1

집어 넣을 때 Appbar에 문제가있는 경우가있었습니다. 부드럽게 스크롤하지 못했습니다.앱바에서 수신 거부 효과를 제거하려면 어떻게해야합니까?

다음을 참조하십시오 :

을하지만 지원 라이브러리 버전에서 수정되었습니다 (26)

compile 'com.android.support:design:26.0.0' 

하지만, 튀김이 어렵지 않더라도 appbar가 이제 튀어 오릅니다.

enter image description here

어떻게이 문제를 제거하는 방법은 무엇입니까?

답변

0

NestedScrollView (또는 RecyclerView)이 아직 끝나지 않은 상태에서 AppBar이 스크롤/플 런닝 될 때만 발생합니다.

해결 방법 : AppBar의 기본 Behavior을 확장하고에 대한 호출을 차단 AppBar.Behavior의 onNestedPreScroll() 및 NestedScroll 아직 중지되지 않은 상태 AppBar을 터치 onNestedScroll().

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar" 
    ... 
    app:layout_behavior="com.mypackage.NoBounceBehavior"/> 

사용자 정의 행동의 전체 코드에 대한 참조는 여기에서 찾을 수 있습니다 : https://gist.github.com/ampatron/9d56ea401094f67196f407f82f14551a

@Override 
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) { 
    if (type == TYPE_FLING) { 
     isFlinging = true; 
    } 
    if (!shouldBlockNestedScroll) { 
     super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type); 
    } 
} 

@Override 
public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) { 
    if (!shouldBlockNestedScroll) { 
     super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type); 
    } 
} 

다음 레이아웃에 사용