• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view;
18 
19 import android.graphics.Rect;
20 import android.os.Bundle;
21 import android.view.accessibility.AccessibilityEvent;
22 
23 /**
24  * Defines the responsibilities for a class that will be a parent of a View.
25  * This is the API that a view sees when it wants to interact with its parent.
26  *
27  */
28 public interface ViewParent {
29     /**
30      * Called when something has changed which has invalidated the layout of a
31      * child of this view parent. This will schedule a layout pass of the view
32      * tree.
33      */
requestLayout()34     public void requestLayout();
35 
36     /**
37      * Indicates whether layout was requested on this view parent.
38      *
39      * @return true if layout was requested, false otherwise
40      */
isLayoutRequested()41     public boolean isLayoutRequested();
42 
43     /**
44      * Called when a child wants the view hierarchy to gather and report
45      * transparent regions to the window compositor. Views that "punch" holes in
46      * the view hierarchy, such as SurfaceView can use this API to improve
47      * performance of the system. When no such a view is present in the
48      * hierarchy, this optimization in unnecessary and might slightly reduce the
49      * view hierarchy performance.
50      *
51      * @param child the view requesting the transparent region computation
52      *
53      */
requestTransparentRegion(View child)54     public void requestTransparentRegion(View child);
55 
56     /**
57      * All or part of a child is dirty and needs to be redrawn.
58      *
59      * @param child The child which is dirty
60      * @param r The area within the child that is invalid
61      */
invalidateChild(View child, Rect r)62     public void invalidateChild(View child, Rect r);
63 
64     /**
65      * All or part of a child is dirty and needs to be redrawn.
66      *
67      * <p>The location array is an array of two int values which respectively
68      * define the left and the top position of the dirty child.</p>
69      *
70      * <p>This method must return the parent of this ViewParent if the specified
71      * rectangle must be invalidated in the parent. If the specified rectangle
72      * does not require invalidation in the parent or if the parent does not
73      * exist, this method must return null.</p>
74      *
75      * <p>When this method returns a non-null value, the location array must
76      * have been updated with the left and top coordinates of this ViewParent.</p>
77      *
78      * @param location An array of 2 ints containing the left and top
79      *        coordinates of the child to invalidate
80      * @param r The area within the child that is invalid
81      *
82      * @return the parent of this ViewParent or null
83      */
invalidateChildInParent(int[] location, Rect r)84     public ViewParent invalidateChildInParent(int[] location, Rect r);
85 
86     /**
87      * Returns the parent if it exists, or null.
88      *
89      * @return a ViewParent or null if this ViewParent does not have a parent
90      */
getParent()91     public ViewParent getParent();
92 
93     /**
94      * Called when a child of this parent wants focus
95      *
96      * @param child The child of this ViewParent that wants focus. This view
97      *        will contain the focused view. It is not necessarily the view that
98      *        actually has focus.
99      * @param focused The view that is a descendant of child that actually has
100      *        focus
101      */
requestChildFocus(View child, View focused)102     public void requestChildFocus(View child, View focused);
103 
104     /**
105      * Tell view hierarchy that the global view attributes need to be
106      * re-evaluated.
107      *
108      * @param child View whose attributes have changed.
109      */
recomputeViewAttributes(View child)110     public void recomputeViewAttributes(View child);
111 
112     /**
113      * Called when a child of this parent is giving up focus
114      *
115      * @param child The view that is giving up focus
116      */
clearChildFocus(View child)117     public void clearChildFocus(View child);
118 
119     /**
120      * Compute the visible part of a rectangular region defined in terms of a child view's
121      * coordinates.
122      *
123      * <p>Returns the clipped visible part of the rectangle <code>r</code>, defined in the
124      * <code>child</code>'s local coordinate system. <code>r</code> is modified by this method to
125      * contain the result, expressed in the global (root) coordinate system.</p>
126      *
127      * <p>The resulting rectangle is always axis aligned. If a rotation is applied to a node in the
128      * View hierarchy, the result is the axis-aligned bounding box of the visible rectangle.</p>
129      *
130      * @param child A child View, whose rectangular visible region we want to compute
131      * @param r The input rectangle, defined in the child coordinate system. Will be overwritten to
132      * contain the resulting visible rectangle, expressed in global (root) coordinates
133      * @param offset The input coordinates of a point, defined in the child coordinate system.
134      * As with the <code>r</code> parameter, this will be overwritten to contain the global (root)
135      * coordinates of that point.
136      * A <code>null</code> value is valid (in case you are not interested in this result)
137      * @return true if the resulting rectangle is not empty, false otherwise
138      */
getChildVisibleRect(View child, Rect r, android.graphics.Point offset)139     public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset);
140 
141     /**
142      * Find the nearest view in the specified direction that wants to take focus
143      *
144      * @param v The view that currently has focus
145      * @param direction One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
146      */
focusSearch(View v, int direction)147     public View focusSearch(View v, int direction);
148 
149     /**
150      * Change the z order of the child so it's on top of all other children.
151      * This ordering change may affect layout, if this container
152      * uses an order-dependent layout scheme (e.g., LinearLayout). Prior
153      * to {@link android.os.Build.VERSION_CODES#KITKAT} this
154      * method should be followed by calls to {@link #requestLayout()} and
155      * {@link View#invalidate()} on this parent to force the parent to redraw
156      * with the new child ordering.
157      *
158      * @param child The child to bring to the top of the z order
159      */
bringChildToFront(View child)160     public void bringChildToFront(View child);
161 
162     /**
163      * Tells the parent that a new focusable view has become available. This is
164      * to handle transitions from the case where there are no focusable views to
165      * the case where the first focusable view appears.
166      *
167      * @param v The view that has become newly focusable
168      */
focusableViewAvailable(View v)169     public void focusableViewAvailable(View v);
170 
171     /**
172      * Shows the context menu for the specified view or its ancestors.
173      * <p>
174      * In most cases, a subclass does not need to override this. However, if
175      * the subclass is added directly to the window manager (for example,
176      * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
177      * then it should override this and show the context menu.
178      *
179      * @param originalView the source view where the context menu was first
180      *                     invoked
181      * @return {@code true} if the context menu was shown, {@code false}
182      *         otherwise
183      * @see #showContextMenuForChild(View, float, float)
184      */
showContextMenuForChild(View originalView)185     public boolean showContextMenuForChild(View originalView);
186 
187     /**
188      * Shows the context menu for the specified view or its ancestors anchored
189      * to the specified view-relative coordinate.
190      * <p>
191      * In most cases, a subclass does not need to override this. However, if
192      * the subclass is added directly to the window manager (for example,
193      * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
194      * then it should override this and show the context menu.
195      * <p>
196      * If a subclass overrides this method it should also override
197      * {@link #showContextMenuForChild(View)}.
198      *
199      * @param originalView the source view where the context menu was first
200      *                     invoked
201      * @param x the X coordinate in pixels relative to the original view to
202      *          which the menu should be anchored, or {@link Float#NaN} to
203      *          disable anchoring
204      * @param y the Y coordinate in pixels relative to the original view to
205      *          which the menu should be anchored, or {@link Float#NaN} to
206      *          disable anchoring
207      * @return {@code true} if the context menu was shown, {@code false}
208      *         otherwise
209      */
showContextMenuForChild(View originalView, float x, float y)210     boolean showContextMenuForChild(View originalView, float x, float y);
211 
212     /**
213      * Have the parent populate the specified context menu if it has anything to
214      * add (and then recurse on its parent).
215      *
216      * @param menu The menu to populate
217      */
createContextMenu(ContextMenu menu)218     public void createContextMenu(ContextMenu menu);
219 
220     /**
221      * Start an action mode for the specified view with the default type
222      * {@link ActionMode#TYPE_PRIMARY}.
223      *
224      * <p>In most cases, a subclass does not need to override this. However, if the
225      * subclass is added directly to the window manager (for example,
226      * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
227      * then it should override this and start the action mode.</p>
228      *
229      * @param originalView The source view where the action mode was first invoked
230      * @param callback The callback that will handle lifecycle events for the action mode
231      * @return The new action mode if it was started, null otherwise
232      *
233      * @see #startActionModeForChild(View, android.view.ActionMode.Callback, int)
234      */
startActionModeForChild(View originalView, ActionMode.Callback callback)235     public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback);
236 
237     /**
238      * Start an action mode of a specific type for the specified view.
239      *
240      * <p>In most cases, a subclass does not need to override this. However, if the
241      * subclass is added directly to the window manager (for example,
242      * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
243      * then it should override this and start the action mode.</p>
244      *
245      * @param originalView The source view where the action mode was first invoked
246      * @param callback The callback that will handle lifecycle events for the action mode
247      * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
248      * @return The new action mode if it was started, null otherwise
249      */
startActionModeForChild( View originalView, ActionMode.Callback callback, int type)250     public ActionMode startActionModeForChild(
251             View originalView, ActionMode.Callback callback, int type);
252 
253     /**
254      * This method is called on the parent when a child's drawable state
255      * has changed.
256      *
257      * @param child The child whose drawable state has changed.
258      */
childDrawableStateChanged(View child)259     public void childDrawableStateChanged(View child);
260 
261     /**
262      * Called when a child does not want this parent and its ancestors to
263      * intercept touch events with
264      * {@link ViewGroup#onInterceptTouchEvent(MotionEvent)}.
265      *
266      * <p>This parent should pass this call onto its parents. This parent must obey
267      * this request for the duration of the touch (that is, only clear the flag
268      * after this parent has received an up or a cancel.</p>
269      *
270      * @param disallowIntercept True if the child does not want the parent to
271      *            intercept touch events.
272      */
requestDisallowInterceptTouchEvent(boolean disallowIntercept)273     public void requestDisallowInterceptTouchEvent(boolean disallowIntercept);
274 
275     /**
276      * Called when a child of this group wants a particular rectangle to be
277      * positioned onto the screen.  {@link ViewGroup}s overriding this can trust
278      * that:
279      * <ul>
280      *   <li>child will be a direct child of this group</li>
281      *   <li>rectangle will be in the child's content coordinates</li>
282      * </ul>
283      *
284      * <p>{@link ViewGroup}s overriding this should uphold the contract:</p>
285      * <ul>
286      *   <li>nothing will change if the rectangle is already visible</li>
287      *   <li>the view port will be scrolled only just enough to make the
288      *       rectangle visible</li>
289      * <ul>
290      *
291      * @param child The direct child making the request.
292      * @param rectangle The rectangle in the child's coordinates the child
293      *        wishes to be on the screen.
294      * @param immediate True to forbid animated or delayed scrolling,
295      *        false otherwise
296      * @return Whether the group scrolled to handle the operation
297      */
requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)298     public boolean requestChildRectangleOnScreen(View child, Rect rectangle,
299             boolean immediate);
300 
301     /**
302      * Called by a child to request from its parent to send an {@link AccessibilityEvent}.
303      * The child has already populated a record for itself in the event and is delegating
304      * to its parent to send the event. The parent can optionally add a record for itself.
305      * <p>
306      * Note: An accessibility event is fired by an individual view which populates the
307      *       event with a record for its state and requests from its parent to perform
308      *       the sending. The parent can optionally add a record for itself before
309      *       dispatching the request to its parent. A parent can also choose not to
310      *       respect the request for sending the event. The accessibility event is sent
311      *       by the topmost view in the view tree.</p>
312      *
313      * @param child The child which requests sending the event.
314      * @param event The event to be sent.
315      * @return True if the event was sent.
316      */
requestSendAccessibilityEvent(View child, AccessibilityEvent event)317     public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event);
318 
319     /**
320      * Called when a child view now has or no longer is tracking transient state.
321      *
322      * <p>"Transient state" is any state that a View might hold that is not expected to
323      * be reflected in the data model that the View currently presents. This state only
324      * affects the presentation to the user within the View itself, such as the current
325      * state of animations in progress or the state of a text selection operation.</p>
326      *
327      * <p>Transient state is useful for hinting to other components of the View system
328      * that a particular view is tracking something complex but encapsulated.
329      * A <code>ListView</code> for example may acknowledge that list item Views
330      * with transient state should be preserved within their position or stable item ID
331      * instead of treating that view as trivially replaceable by the backing adapter.
332      * This allows adapter implementations to be simpler instead of needing to track
333      * the state of item view animations in progress such that they could be restored
334      * in the event of an unexpected recycling and rebinding of attached item views.</p>
335      *
336      * <p>This method is called on a parent view when a child view or a view within
337      * its subtree begins or ends tracking of internal transient state.</p>
338      *
339      * @param child Child view whose state has changed
340      * @param hasTransientState true if this child has transient state
341      */
childHasTransientStateChanged(View child, boolean hasTransientState)342     public void childHasTransientStateChanged(View child, boolean hasTransientState);
343 
344     /**
345      * Ask that a new dispatch of {@link View#fitSystemWindows(Rect)
346      * View.fitSystemWindows(Rect)} be performed.
347      */
requestFitSystemWindows()348     public void requestFitSystemWindows();
349 
350     /**
351      * Gets the parent of a given View for accessibility. Since some Views are not
352      * exposed to the accessibility layer the parent for accessibility is not
353      * necessarily the direct parent of the View, rather it is a predecessor.
354      *
355      * @return The parent or <code>null</code> if no such is found.
356      */
getParentForAccessibility()357     public ViewParent getParentForAccessibility();
358 
359     /**
360      * Notifies a view parent that the accessibility state of one of its
361      * descendants has changed and that the structure of the subtree is
362      * different.
363      * @param child The direct child whose subtree has changed.
364      * @param source The descendant view that changed.
365      * @param changeType A bit mask of the types of changes that occurred. One
366      *            or more of:
367      *            <ul>
368      *            <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION}
369      *            <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE}
370      *            <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_TEXT}
371      *            <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_UNDEFINED}
372      *            </ul>
373      */
notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)374     public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType);
375 
376     /**
377      * Tells if this view parent can resolve the layout direction.
378      * See {@link View#setLayoutDirection(int)}
379      *
380      * @return True if this view parent can resolve the layout direction.
381      */
canResolveLayoutDirection()382     public boolean canResolveLayoutDirection();
383 
384     /**
385      * Tells if this view parent layout direction is resolved.
386      * See {@link View#setLayoutDirection(int)}
387      *
388      * @return True if this view parent layout direction is resolved.
389      */
isLayoutDirectionResolved()390     public boolean isLayoutDirectionResolved();
391 
392     /**
393      * Return this view parent layout direction. See {@link View#getLayoutDirection()}
394      *
395      * @return {@link View#LAYOUT_DIRECTION_RTL} if the layout direction is RTL or returns
396      * {@link View#LAYOUT_DIRECTION_LTR} if the layout direction is not RTL.
397      */
getLayoutDirection()398     public int getLayoutDirection();
399 
400     /**
401      * Tells if this view parent can resolve the text direction.
402      * See {@link View#setTextDirection(int)}
403      *
404      * @return True if this view parent can resolve the text direction.
405      */
canResolveTextDirection()406     public boolean canResolveTextDirection();
407 
408     /**
409      * Tells if this view parent text direction is resolved.
410      * See {@link View#setTextDirection(int)}
411      *
412      * @return True if this view parent text direction is resolved.
413      */
isTextDirectionResolved()414     public boolean isTextDirectionResolved();
415 
416     /**
417      * Return this view parent text direction. See {@link View#getTextDirection()}
418      *
419      * @return the resolved text direction. Returns one of:
420      *
421      * {@link View#TEXT_DIRECTION_FIRST_STRONG}
422      * {@link View#TEXT_DIRECTION_ANY_RTL},
423      * {@link View#TEXT_DIRECTION_LTR},
424      * {@link View#TEXT_DIRECTION_RTL},
425      * {@link View#TEXT_DIRECTION_LOCALE}
426      */
getTextDirection()427     public int getTextDirection();
428 
429     /**
430      * Tells if this view parent can resolve the text alignment.
431      * See {@link View#setTextAlignment(int)}
432      *
433      * @return True if this view parent can resolve the text alignment.
434      */
canResolveTextAlignment()435     public boolean canResolveTextAlignment();
436 
437     /**
438      * Tells if this view parent text alignment is resolved.
439      * See {@link View#setTextAlignment(int)}
440      *
441      * @return True if this view parent text alignment is resolved.
442      */
isTextAlignmentResolved()443     public boolean isTextAlignmentResolved();
444 
445     /**
446      * Return this view parent text alignment. See {@link android.view.View#getTextAlignment()}
447      *
448      * @return the resolved text alignment. Returns one of:
449      *
450      * {@link View#TEXT_ALIGNMENT_GRAVITY},
451      * {@link View#TEXT_ALIGNMENT_CENTER},
452      * {@link View#TEXT_ALIGNMENT_TEXT_START},
453      * {@link View#TEXT_ALIGNMENT_TEXT_END},
454      * {@link View#TEXT_ALIGNMENT_VIEW_START},
455      * {@link View#TEXT_ALIGNMENT_VIEW_END}
456      */
getTextAlignment()457     public int getTextAlignment();
458 
459     /**
460      * React to a descendant view initiating a nestable scroll operation, claiming the
461      * nested scroll operation if appropriate.
462      *
463      * <p>This method will be called in response to a descendant view invoking
464      * {@link View#startNestedScroll(int)}. Each parent up the view hierarchy will be
465      * given an opportunity to respond and claim the nested scrolling operation by returning
466      * <code>true</code>.</p>
467      *
468      * <p>This method may be overridden by ViewParent implementations to indicate when the view
469      * is willing to support a nested scrolling operation that is about to begin. If it returns
470      * true, this ViewParent will become the target view's nested scrolling parent for the duration
471      * of the scroll operation in progress. When the nested scroll is finished this ViewParent
472      * will receive a call to {@link #onStopNestedScroll(View)}.
473      * </p>
474      *
475      * @param child Direct child of this ViewParent containing target
476      * @param target View that initiated the nested scroll
477      * @param nestedScrollAxes Flags consisting of {@link View#SCROLL_AXIS_HORIZONTAL},
478      *                         {@link View#SCROLL_AXIS_VERTICAL} or both
479      * @return true if this ViewParent accepts the nested scroll operation
480      */
onStartNestedScroll(View child, View target, int nestedScrollAxes)481     public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes);
482 
483     /**
484      * React to the successful claiming of a nested scroll operation.
485      *
486      * <p>This method will be called after
487      * {@link #onStartNestedScroll(View, View, int) onStartNestedScroll} returns true. It offers
488      * an opportunity for the view and its superclasses to perform initial configuration
489      * for the nested scroll. Implementations of this method should always call their superclass's
490      * implementation of this method if one is present.</p>
491      *
492      * @param child Direct child of this ViewParent containing target
493      * @param target View that initiated the nested scroll
494      * @param nestedScrollAxes Flags consisting of {@link View#SCROLL_AXIS_HORIZONTAL},
495      *                         {@link View#SCROLL_AXIS_VERTICAL} or both
496      * @see #onStartNestedScroll(View, View, int)
497      * @see #onStopNestedScroll(View)
498      */
onNestedScrollAccepted(View child, View target, int nestedScrollAxes)499     public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes);
500 
501     /**
502      * React to a nested scroll operation ending.
503      *
504      * <p>Perform cleanup after a nested scrolling operation.
505      * This method will be called when a nested scroll stops, for example when a nested touch
506      * scroll ends with a {@link MotionEvent#ACTION_UP} or {@link MotionEvent#ACTION_CANCEL} event.
507      * Implementations of this method should always call their superclass's implementation of this
508      * method if one is present.</p>
509      *
510      * @param target View that initiated the nested scroll
511      */
onStopNestedScroll(View target)512     public void onStopNestedScroll(View target);
513 
514     /**
515      * React to a nested scroll in progress.
516      *
517      * <p>This method will be called when the ViewParent's current nested scrolling child view
518      * dispatches a nested scroll event. To receive calls to this method the ViewParent must have
519      * previously returned <code>true</code> for a call to
520      * {@link #onStartNestedScroll(View, View, int)}.</p>
521      *
522      * <p>Both the consumed and unconsumed portions of the scroll distance are reported to the
523      * ViewParent. An implementation may choose to use the consumed portion to match or chase scroll
524      * position of multiple child elements, for example. The unconsumed portion may be used to
525      * allow continuous dragging of multiple scrolling or draggable elements, such as scrolling
526      * a list within a vertical drawer where the drawer begins dragging once the edge of inner
527      * scrolling content is reached.</p>
528      *
529      * @param target The descendent view controlling the nested scroll
530      * @param dxConsumed Horizontal scroll distance in pixels already consumed by target
531      * @param dyConsumed Vertical scroll distance in pixels already consumed by target
532      * @param dxUnconsumed Horizontal scroll distance in pixels not consumed by target
533      * @param dyUnconsumed Vertical scroll distance in pixels not consumed by target
534      */
onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)535     public void onNestedScroll(View target, int dxConsumed, int dyConsumed,
536             int dxUnconsumed, int dyUnconsumed);
537 
538     /**
539      * React to a nested scroll in progress before the target view consumes a portion of the scroll.
540      *
541      * <p>When working with nested scrolling often the parent view may want an opportunity
542      * to consume the scroll before the nested scrolling child does. An example of this is a
543      * drawer that contains a scrollable list. The user will want to be able to scroll the list
544      * fully into view before the list itself begins scrolling.</p>
545      *
546      * <p><code>onNestedPreScroll</code> is called when a nested scrolling child invokes
547      * {@link View#dispatchNestedPreScroll(int, int, int[], int[])}. The implementation should
548      * report how any pixels of the scroll reported by dx, dy were consumed in the
549      * <code>consumed</code> array. Index 0 corresponds to dx and index 1 corresponds to dy.
550      * This parameter will never be null. Initial values for consumed[0] and consumed[1]
551      * will always be 0.</p>
552      *
553      * @param target View that initiated the nested scroll
554      * @param dx Horizontal scroll distance in pixels
555      * @param dy Vertical scroll distance in pixels
556      * @param consumed Output. The horizontal and vertical scroll distance consumed by this parent
557      */
onNestedPreScroll(View target, int dx, int dy, int[] consumed)558     public void onNestedPreScroll(View target, int dx, int dy, int[] consumed);
559 
560     /**
561      * Request a fling from a nested scroll.
562      *
563      * <p>This method signifies that a nested scrolling child has detected suitable conditions
564      * for a fling. Generally this means that a touch scroll has ended with a
565      * {@link VelocityTracker velocity} in the direction of scrolling that meets or exceeds
566      * the {@link ViewConfiguration#getScaledMinimumFlingVelocity() minimum fling velocity}
567      * along a scrollable axis.</p>
568      *
569      * <p>If a nested scrolling child view would normally fling but it is at the edge of
570      * its own content, it can use this method to delegate the fling to its nested scrolling
571      * parent instead. The parent may optionally consume the fling or observe a child fling.</p>
572      *
573      * @param target View that initiated the nested scroll
574      * @param velocityX Horizontal velocity in pixels per second
575      * @param velocityY Vertical velocity in pixels per second
576      * @param consumed true if the child consumed the fling, false otherwise
577      * @return true if this parent consumed or otherwise reacted to the fling
578      */
onNestedFling(View target, float velocityX, float velocityY, boolean consumed)579     public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed);
580 
581     /**
582      * React to a nested fling before the target view consumes it.
583      *
584      * <p>This method siginfies that a nested scrolling child has detected a fling with the given
585      * velocity along each axis. Generally this means that a touch scroll has ended with a
586      * {@link VelocityTracker velocity} in the direction of scrolling that meets or exceeds
587      * the {@link ViewConfiguration#getScaledMinimumFlingVelocity() minimum fling velocity}
588      * along a scrollable axis.</p>
589      *
590      * <p>If a nested scrolling parent is consuming motion as part of a
591      * {@link #onNestedPreScroll(View, int, int, int[]) pre-scroll}, it may be appropriate for
592      * it to also consume the pre-fling to complete that same motion. By returning
593      * <code>true</code> from this method, the parent indicates that the child should not
594      * fling its own internal content as well.</p>
595      *
596      * @param target View that initiated the nested scroll
597      * @param velocityX Horizontal velocity in pixels per second
598      * @param velocityY Vertical velocity in pixels per second
599      * @return true if this parent consumed the fling ahead of the target view
600      */
onNestedPreFling(View target, float velocityX, float velocityY)601     public boolean onNestedPreFling(View target, float velocityX, float velocityY);
602 
603     /**
604      * React to an accessibility action delegated by a target descendant view before the target
605      * processes it.
606      *
607      * <p>This method may be called by a target descendant view if the target wishes to give
608      * a view in its parent chain a chance to react to the event before normal processing occurs.
609      * Most commonly this will be a scroll event such as
610      * {@link android.view.accessibility.AccessibilityNodeInfo#ACTION_SCROLL_FORWARD}.
611      * A ViewParent that supports acting as a nested scrolling parent should override this
612      * method and act accordingly to implement scrolling via accesibility systems.</p>
613      *
614      * @param target The target view dispatching this action
615      * @param action Action being performed; see
616      *               {@link android.view.accessibility.AccessibilityNodeInfo}
617      * @param arguments Optional action arguments
618      * @return true if the action was consumed by this ViewParent
619      */
onNestedPrePerformAccessibilityAction(View target, int action, Bundle arguments)620     public boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle arguments);
621 }
622