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