11fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell/* 21fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Copyright (C) 2015 The Android Open Source Project 31fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 41fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 51fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * you may not use this file except in compliance with the License. 61fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * You may obtain a copy of the License at 71fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 81fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * http://www.apache.org/licenses/LICENSE-2.0 91fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 101fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Unless required by applicable law or agreed to in writing, software 111fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * distributed under the License is distributed on an "AS IS" BASIS, 121fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * See the License for the specific language governing permissions and 141fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * limitations under the License. 151fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 161fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 171fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 181fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellpackage android.support.v4.view; 191fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 201fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellimport android.view.MotionEvent; 211fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellimport android.view.VelocityTracker; 221fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellimport android.view.View; 231fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellimport android.view.ViewConfiguration; 241fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellimport android.view.ViewParent; 251fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 261fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell/** 271fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * This interface should be implemented by {@link android.view.View View} subclasses that wish 281fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * to support dispatching nested scrolling operations to a cooperating parent 291fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link android.view.ViewGroup ViewGroup}. 301fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 311fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Classes implementing this interface should create a final instance of a 321fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link NestedScrollingChildHelper} as a field and delegate any View methods to the 331fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <code>NestedScrollingChildHelper</code> methods of the same signature.</p> 341fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 351fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Views invoking nested scrolling functionality should always do so from the relevant 361fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link ViewCompat}, {@link ViewGroupCompat} or {@link ViewParentCompat} compatibility 371fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * shim static methods. This ensures interoperability with nested scrolling views on Android 381fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 5.0 Lollipop and newer.</p> 391fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 401fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powellpublic interface NestedScrollingChild { 411fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 421fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Enable or disable nested scrolling for this view. 431fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 441fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>If this property is set to true the view will be permitted to initiate nested 451fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * scrolling operations with a compatible parent view in the current hierarchy. If this 461fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * view does not implement nested scrolling this will have no effect. Disabling nested scrolling 471fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * while a nested scroll is in progress has the effect of {@link #stopNestedScroll() stopping} 481fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * the nested scroll.</p> 491fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 501fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param enabled true to enable nested scrolling, false to disable 511fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 521fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #isNestedScrollingEnabled() 531fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 541fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public void setNestedScrollingEnabled(boolean enabled); 551fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 561fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 571fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Returns true if nested scrolling is enabled for this view. 581fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 591fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>If nested scrolling is enabled and this View class implementation supports it, 601fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * this view will act as a nested scrolling child view when applicable, forwarding data 611fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * about the scroll operation in progress to a compatible and cooperating nested scrolling 621fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * parent.</p> 631fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 641fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return true if nested scrolling is enabled 651fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 661fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #setNestedScrollingEnabled(boolean) 671fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 681fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean isNestedScrollingEnabled(); 691fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 701fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 711fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Begin a nestable scroll operation along the given axes. 721fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 731fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>A view starting a nested scroll promises to abide by the following contract:</p> 741fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 751fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>The view will call startNestedScroll upon initiating a scroll operation. In the case 761fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * of a touch scroll this corresponds to the initial {@link MotionEvent#ACTION_DOWN}. 771fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * In the case of touch scrolling the nested scroll will be terminated automatically in 781fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * the same manner as {@link ViewParent#requestDisallowInterceptTouchEvent(boolean)}. 791fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * In the event of programmatic scrolling the caller must explicitly call 801fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link #stopNestedScroll()} to indicate the end of the nested scroll.</p> 811fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 821fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>If <code>startNestedScroll</code> returns true, a cooperative parent was found. 831fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * If it returns false the caller may ignore the rest of this contract until the next scroll. 841fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Calling startNestedScroll while a nested scroll is already in progress will return true.</p> 851fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 861fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>At each incremental step of the scroll the caller should invoke 871fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link #dispatchNestedPreScroll(int, int, int[], int[]) dispatchNestedPreScroll} 881fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * once it has calculated the requested scrolling delta. If it returns true the nested scrolling 891fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * parent at least partially consumed the scroll and the caller should adjust the amount it 901fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * scrolls by.</p> 911fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 921fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>After applying the remainder of the scroll delta the caller should invoke 931fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link #dispatchNestedScroll(int, int, int, int, int[]) dispatchNestedScroll}, passing 941fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * both the delta consumed and the delta unconsumed. A nested scrolling parent may treat 951fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * these values differently. See 961fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link NestedScrollingParent#onNestedScroll(View, int, int, int, int)}. 971fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * </p> 981fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 991fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param axes Flags consisting of a combination of {@link ViewCompat#SCROLL_AXIS_HORIZONTAL} 1001fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * and/or {@link ViewCompat#SCROLL_AXIS_VERTICAL}. 1011fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return true if a cooperative parent was found and nested scrolling has been enabled for 1021fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * the current gesture. 1031fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1041fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #stopNestedScroll() 1051fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #dispatchNestedPreScroll(int, int, int[], int[]) 1061fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #dispatchNestedScroll(int, int, int, int, int[]) 1071fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 1081fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean startNestedScroll(int axes); 1091fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 1101fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 1111fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Stop a nested scroll in progress. 1121fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1131fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Calling this method when a nested scroll is not currently in progress is harmless.</p> 1141fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1151fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #startNestedScroll(int) 1161fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 1171fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public void stopNestedScroll(); 1181fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 1191fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 1201fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Returns true if this view has a nested scrolling parent. 1211fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1221fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>The presence of a nested scrolling parent indicates that this view has initiated 1231fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * a nested scroll and it was accepted by an ancestor view further up the view hierarchy.</p> 1241fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1251fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return whether this view has a nested scrolling parent 1261fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 1271fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean hasNestedScrollingParent(); 1281fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 1291fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 1301fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Dispatch one step of a nested scroll in progress. 1311fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1321fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Implementations of views that support nested scrolling should call this to report 1331fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * info about a scroll in progress to the current nested scrolling parent. If a nested scroll 1341fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * is not currently in progress or nested scrolling is not 1351fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link #isNestedScrollingEnabled() enabled} for this view this method does nothing.</p> 1361fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1371fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Compatible View implementations should also call 1381fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link #dispatchNestedPreScroll(int, int, int[], int[]) dispatchNestedPreScroll} before 1391fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * consuming a component of the scroll event themselves.</p> 1401fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1411fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param dxConsumed Horizontal distance in pixels consumed by this view during this scroll step 1421fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param dyConsumed Vertical distance in pixels consumed by this view during this scroll step 1431fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param dxUnconsumed Horizontal scroll distance in pixels not consumed by this view 1441fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param dyUnconsumed Horizontal scroll distance in pixels not consumed by this view 1451fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param offsetInWindow Optional. If not null, on return this will contain the offset 1461fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * in local view coordinates of this view from before this operation 1471fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * to after it completes. View implementations may use this to adjust 1481fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * expected input coordinate tracking. 1491fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return true if the event was dispatched, false if it could not be dispatched. 1501fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #dispatchNestedPreScroll(int, int, int[], int[]) 1511fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 1521fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, 1531fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); 1541fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 1551fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 1561fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Dispatch one step of a nested scroll in progress before this view consumes any portion of it. 1571fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1581fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Nested pre-scroll events are to nested scroll events what touch intercept is to touch. 1591fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <code>dispatchNestedPreScroll</code> offers an opportunity for the parent view in a nested 1601fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * scrolling operation to consume some or all of the scroll operation before the child view 1611fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * consumes it.</p> 1621fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1631fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param dx Horizontal scroll distance in pixels 1641fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param dy Vertical scroll distance in pixels 1651fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param consumed Output. If not null, consumed[0] will contain the consumed component of dx 1661fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * and consumed[1] the consumed dy. 1671fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param offsetInWindow Optional. If not null, on return this will contain the offset 1681fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * in local view coordinates of this view from before this operation 1691fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * to after it completes. View implementations may use this to adjust 1701fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * expected input coordinate tracking. 1711fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return true if the parent consumed some or all of the scroll delta 1721fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @see #dispatchNestedScroll(int, int, int, int, int[]) 1731fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 1741fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); 1751fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 1761fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 1771fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Dispatch a fling to a nested scrolling parent. 1781fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1791fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>This method should be used to indicate that a nested scrolling child has detected 1801fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * suitable conditions for a fling. Generally this means that a touch scroll has ended with a 1811fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * {@link VelocityTracker velocity} in the direction of scrolling that meets or exceeds 1821fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * the {@link ViewConfiguration#getScaledMinimumFlingVelocity() minimum fling velocity} 1831fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * along a scrollable axis.</p> 1841fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1851fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>If a nested scrolling child view would normally fling but it is at the edge of 1861fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * its own content, it can use this method to delegate the fling to its nested scrolling 1871fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * parent instead. The parent may optionally consume the fling or observe a child fling.</p> 1881fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1891fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param velocityX Horizontal fling velocity in pixels per second 1901fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param velocityY Vertical fling velocity in pixels per second 1911fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param consumed true if the child consumed the fling, false otherwise 1921fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return true if the nested scrolling parent consumed or otherwise reacted to the fling 1931fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 1941fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); 1951fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell 1961fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell /** 1971fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Dispatch a fling to a nested scrolling parent before it is processed by this view. 1981fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 1991fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Nested pre-fling events are to nested fling events what touch intercept is to touch 2001fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * and what nested pre-scroll is to nested scroll. <code>dispatchNestedPreFling</code> 2011fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * offsets an opportunity for the parent view in a nested fling to fully consume the fling 2021fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * before the child view consumes it. If this method returns <code>true</code>, a nested 2031fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * parent view consumed the fling and this view should not scroll as a result.</p> 2041fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 2051fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>For a better user experience, only one view in a nested scrolling chain should consume 2061fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * the fling at a time. If a parent view consumed the fling this method will return false. 2071fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * Custom view implementations should account for this in two ways:</p> 2081fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 2091fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <ul> 2101fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <li>If a custom view is paged and needs to settle to a fixed page-point, do not 2111fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * call <code>dispatchNestedPreFling</code>; consume the fling and settle to a valid 2121fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * position regardless.</li> 2131fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <li>If a nested parent does consume the fling, this view should not scroll at all, 2141fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * even to settle back to a valid idle position.</li> 2151fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * </ul> 2161fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 2171fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * <p>Views should also not offer fling velocities to nested parent views along an axis 2181fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * where scrolling is not currently supported; a {@link android.widget.ScrollView ScrollView} 2191fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * should not offer a horizontal fling velocity to its parents since scrolling along that 2201fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * axis is not permitted and carrying velocity along that motion does not make sense.</p> 2211fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * 2221fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param velocityX Horizontal fling velocity in pixels per second 2231fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @param velocityY Vertical fling velocity in pixels per second 2241fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell * @return true if a nested scrolling parent consumed the fling 2251fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell */ 2261fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell public boolean dispatchNestedPreFling(float velocityX, float velocityY); 2271fcce4485ef99aca928ebfb877859c5ecd47716cAdam Powell} 228