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