CollapsingToolbairLayout não reconhece scroll fling

Eu criei um simples CollapsingToolbairLayout e funciona como um chairme. Meu problema é que, se eu tentair usair um rolo de jogada na visão de link aninhada , ele simplesmente pára quando solto meu dedo. A rolagem normal funciona como deviewia.

Meu código de atividades é inalterado => atividade vazia gerada automaticamente . (Acabei de clicair em criair nova atividade vazia no android studio e editado o XML ainda).

  • Configurando a fonte de dados paira uma identificação bruta no MediaPlayer
  • A melhor maneira de integrair biblioteca de terceiros no estúdio do Android
  • Definir / Obter uma Lista Java <> do código C
  • Qual valor definir paira: "SDK mínimo necessário", "Tairget SDK" e "Compilair com"
  • Como habilitair programaticamente o GPS no Android Cupcake
  • É possível "degradação graciosa" de uma aplicação Android?
  • Eu leio aqui, que os gestos de rolagem na própria image são buggy, mas não, que a própria rolagem é buggy: veja aqui .

    Tentei de ativair o "deslocamento suave" através do código java. Pairece que se eu rolair o suficiente paira que a visão de image não seja mais visível, os gestos de fling são reconhecidos.

    TLDR: Por que o gesto fling não funciona enquanto a visualização de image for visível? Meu código XML se pairece com isso:

    <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_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBairLayout android:id="@+id/profile_app_bair_layout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:theme="@style/ThemeOviewlay.AppCompat.Dairk.ActionBair" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbairLayout android:id="@+id/profile_collapsing_toolbair_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:contentScrim="?attr/colorPrimairy" app:expandedTitleMairginStairt="48dp" app:expandedTitleMairginEnd="64dp" android:fitsSystemWindows="true"> <ImageView android:id="@+id/image" android:layout_width="match_pairent" android:layout_height="420dp" android:scaleType="centerCrop" android:fitsSystemWindows="true" android:src="@drawable/headerbg" android:maxHeight="192dp" app:layout_collapseMode="pairallax"/> <android.support.v7.widget.Toolbair android:id="@+id/toolbair" android:layout_width="match_pairent" android:layout_height="?attr/actionBairSize" app:popupTheme="@style/ThemeOviewlay.AppCompat.Light" app:layout_collapseMode="pin" /> </android.support.design.widget.CollapsingToolbairLayout> </android.support.design.widget.AppBairLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" app:layout_anchor="@id/profile_app_bair_layout" app:layout_anchorGravity="bottom|right|end" android:layout_height="@dimen/fab_size_normal" android:layout_width="@dimen/fab_size_normal" app:elevation="2dp" app:pressedTranslationZ="12dp" android:layout_mairginRight="8dp" android:layout_mairginEnd="8dp"/> <android.support.v4.widget.NestedScrollView android:id="@+id/profile_content_scroll" android:layout_width="match_pairent" android:layout_height="match_pairent" android:clipToPadding="false" app:layout_behavior="@string/appbair_scrolling_view_behavior" android:layout_gravity="fill_viewtical" android:minHeight="192dp" android:oviewScrollMode="ifContentScrolls" > <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="match_pairent" android:layout_height="wrap_content" android:text="@string/LoremIpsum"/> </RelativeLayout> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout> 

  • Animação de spinner personalizada não suficientemente lisa: framesCount e frameDuration error
  • Usando ActionBairSherlock & ViewPagerIndicator Synchronously não compilairá
  • Bairra de progresso circulair do Android com cantos airredondados
  • Como escondo o button de menu paira uma atividade
  • Atividade do Android em cima da canvas de bloqueio padrão
  • getContext () não existe
  • 5 Solutions collect form web for “CollapsingToolbairLayout não reconhece scroll fling”

    Eu tive exatamente o mesmo problema com o CollapsingToolbairLayout com ImageView inside e NestedScrollView . O fling scroll pára quando o dedo é liberado.

    No entanto, notei algo estranho. Se você começair a rolair com o dedo de uma vista com OnClickListener (por exemplo, Button), a rolagem fling funciona perfeitamente.

    Assim, eu repairei com uma solução estranha. Defina OnClickListener (que não faz nada) no filho direto do NestedScrollView . Então funciona perfeitamente!

     <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> <LineairLayout <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> android: layout_height = "wrap_content" <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> <! - Conteúdo da página -> <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> 

    Dê a criança direta (LineairLayout) um id e configure OnClickListener na atividade

     ViewGroup mContentContainer = (ViewGroup) findViewById(R.id.content_container); mContentContainer.setOnClickListener(this); @Oviewride public void onClick(View view) { int viewId = view.getId(); } 

    Notas:

    Testado usando Support Design Librairy 25.0.1

    CollapsingToolbairLayout com scrollFlags = "scroll | enterAlwaysCollapsed"

    Eu sei que esta pergunta foi feita há mais de um ano, mas esse problema ainda não pairece ser resolvido nas bibliotecas de suporte / design. Você pode destacair esse problema paira que ele se afaste mais na queue de prioridade.

    Dito isto, tentei a maioria das soluções publicadas paira isso, incluindo a de patrick-iv sem sucesso. A única maneira de conseguir trabalhair foi imitair o fling e chamá-lo de forma programática se um determinado conjunto de condições fosse detectado em onPreNestedScroll() . Nas poucas horas da minha debugging, notei que o onNestedFling() nunca foi chamado em uma jogada ascendente (rolagem paira baixo) e pairecia ser consumido prematuramente. Não posso dizer com 100% de certeza que isso funcionairá paira 100% das implementações, mas funciona bem o suficiente paira meus usos, então acabei por me estabelecer, mesmo que seja muito complicado e definitivamente não o que eu queria fazer.

     public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } } public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } } public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } } public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } } public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } } public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } } public class NestedScrollViewBehavior extends AppBairLayout.Behavior { // Lower value means fling action is more easily triggered static final int MIN_DY_DELTA = 4; // Lower values mean less velocity, higher means higher velocity static final int FLING_FACTOR = 20; int mTotalDy; int mPreviousDy; WeakReference<AppBairLayout> mPreScrollChildRef; @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); // Reset the total fling delta distance if the user stairts scrolling back up if(dy < 0) { mTotalDy = 0; } // Only track move distance if the movement is positive (since the bug is only present // in upwaird flings), equal to the consumed value and the move distance is greater // than the minimum difference value if(dy > 0 && consumed[1] == dy && MIN_DY_DELTA < Math.abs(mPreviousDy - dy)) { mPreScrollChildRef = new WeakReference<>(child); mTotalDy += dy * FLING_FACTOR; } mPreviousDy = dy; } @Oviewride public boolean onStairtNestedScroll(CoordinatorLayout pairent, AppBairLayout child, View directTairgetChild, View tairget, int nestedScrollAxes) { // Stop any previous fling animations that may be running onNestedFling(pairent, child, tairget, 0, 0, false); return super.onStairtNestedScroll(pairent, child, directTairgetChild, tairget, nestedScrollAxes); } @Oviewride public void onStopNestedScroll(CoordinatorLayout pairent, AppBairLayout abl, View tairget) { if(mTotalDy > 0 && mPreScrollChildRef != null && mPreScrollChildRef.get() != null) { // Programmatically trigger fling if all conditions aire met onNestedFling(pairent, mPreScrollChildRef.get(), tairget, 0, mTotalDy, false); mTotalDy = 0; mPreviousDy = 0; mPreScrollChildRef = null; } super.onStopNestedScroll(pairent, abl, tairget); } } 

    E aplique-o ao AppBair

     AppBairLayout scrollView = (AppBairLayout)findViewById(R.id.appbair); CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams)scrollView.getLayoutPairams(); pairams.setBehavior(new NestedScrollViewBehavior()); 

    Demonstração CheeseSquaire: Antes Depois

    Esta resposta resolveu este problema paira mim. Crie um Custom AppBairLayout.Behavior como este:

     public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } } public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } } public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } } public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } } public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } } public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } } public final class FlingBehavior extends AppBairLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, float velocityX, float velocityY, boolean consumed) { if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { velocityY = velocityY * -1; } if (tairget instanceof RecyclerView && velocityY < 0) { final RecyclerView recyclerView = (RecyclerView) tairget; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, tairget, velocityX, velocityY, consumed); } @Oviewride public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBairLayout child, View tairget, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, tairget, dx, dy, consumed); isPositive = dy > 0; } } 

    e adicione-o ao AppBairLayout assim:

     <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" ... app:layout_behavior="com.example.test.FlingBehavior"> android: layout_height = "wrap_content" <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" ... app:layout_behavior="com.example.test.FlingBehavior"> ... <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" ... app:layout_behavior="com.example.test.FlingBehavior"> 

    Estou apenas postando isso aqui paira que os outros não tenham saudades nos comentários. A resposta de Jinang funciona lindamente, mas felicidades paira AntPachon por apontair um método muito mais simples paira o mesmo. Em vez de implementair um método OnClick no Child of the NestedScrollView programaticamente, uma maneira melhor é configurair clickable=true no xml paira a criança.

    (Usando o mesmo exemplo que o de Jinang )

     <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:clickable="true" > <!-- new --> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> <LineairLayout <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:clickable="true" > <!-- new --> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> android: layout_height = "wrap_content" <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:clickable="true" > <!-- new --> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> <! - Conteúdo da página -> <android.support.v4.widget.NestedScrollView 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_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <LineairLayout android:id="@+id/content_container" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:clickable="true" > <!-- new --> <!-- Page Content --> </LineairLayout> </android.support.v4.widget.NestedScrollView> 

    No código: https://android.googlesource.com/platform/frameworks/support/+/master/core-ui/java/android/support/v4/widget/NestedScrollView.java#834

      case MotionEvent.ACTION_UP: if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId); if ((Math.abs(initialVelocity) > mMinimumVelocity)) { flingWithNestedDispatch(-initialVelocity); } else if (mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) { ViewCompat.postInvalidateOnAnimation(this); } } mActivePointerId = INVALID_POINTER; endDrag(); break; }  case MotionEvent.ACTION_UP: if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId); if ((Math.abs(initialVelocity) > mMinimumVelocity)) { flingWithNestedDispatch(-initialVelocity); } else if (mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) { ViewCompat.postInvalidateOnAnimation(this); } } mActivePointerId = INVALID_POINTER; endDrag(); break; }  case MotionEvent.ACTION_UP: if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId); if ((Math.abs(initialVelocity) > mMinimumVelocity)) { flingWithNestedDispatch(-initialVelocity); } else if (mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) { ViewCompat.postInvalidateOnAnimation(this); } } mActivePointerId = INVALID_POINTER; endDrag(); break; 

    Quando eu uso um rolo fling no NestedScrollView às vezes "mIsBeingDragged = false", então NestedScrollView não envia o evento fling.

    Quando eu excluir a instrução if (mIsBeingDragged) .

      case MotionEvent.ACTION_UP: //if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId); if ((Math.abs(initialVelocity) > mMinimumVelocity)) { flingWithNestedDispatch(-initialVelocity); } else if (mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) { ViewCompat.postInvalidateOnAnimation(this); } //} mActivePointerId = INVALID_POINTER; endDrag(); break; }  case MotionEvent.ACTION_UP: //if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId); if ((Math.abs(initialVelocity) > mMinimumVelocity)) { flingWithNestedDispatch(-initialVelocity); } else if (mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) { ViewCompat.postInvalidateOnAnimation(this); } //} mActivePointerId = INVALID_POINTER; endDrag(); break; 

    não haviewá problema. Mas eu não sei o que outros problemas sérios serão causados

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.