Lines Matching refs:child

74  *     <li>As a container for a specific interaction with one or more child views</li>
77 * <p>By specifying {@link CoordinatorLayout.Behavior Behaviors} for child views of a
80 * used as a child of a CoordinatorLayout using the
89 * to an arbitrary descendant of the CoordinatorLayout, but it may not be the anchored child itself
90 * or a descendant of the anchored child. This can be used to place floating views relative to
372 final View child = getChildAt(i);
373 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
380 * Populate a list with the current child views, sorted such that the topmost views
390 final View child = getChildAt(childIndex);
391 out.add(child);
410 // Let topmost child views inspect first
413 final View child = topmostChildList.get(i);
414 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
428 b.onInterceptTouchEvent(this, child, cancelEvent);
431 b.onTouchEvent(this, child, cancelEvent);
441 intercepted = b.onInterceptTouchEvent(this, child, ev);
444 intercepted = b.onTouchEvent(this, child, ev);
448 mBehaviorTouchView = child;
455 final boolean isBlocking = lp.isBlockingInteractionBelow(this, child);
600 LayoutParams getResolvedLayoutParams(View child) {
601 final LayoutParams result = (LayoutParams) child.getLayoutParams();
603 Class<?> childClass = child.getClass();
625 final View child = getChildAt(i);
627 final LayoutParams lp = getResolvedLayoutParams(child);
628 lp.findAnchorView(this, child);
630 mDependencySortedChildren.add(child);
639 * This does not need to be a direct child.
659 * Called to measure each individual child view unless a
661 * child measurement to this method.
663 * @param child the child to measure
671 public void onMeasureChild(View child, int parentWidthMeasureSpec, int widthUsed,
673 measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed,
703 final View child = mDependencySortedChildren.get(i);
704 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
723 if (applyInsets && !ViewCompat.getFitsSystemWindows(child)) {
724 // We're set to handle insets but this child isn't, so we will measure the
725 // child as if there are no insets
738 if (b == null || !b.onMeasureChild(this, child, childWidthMeasureSpec, keylineWidthUsed,
740 onMeasureChild(child, childWidthMeasureSpec, keylineWidthUsed,
744 widthUsed = Math.max(widthUsed, widthPadding + child.getMeasuredWidth() +
747 heightUsed = Math.max(heightUsed, heightPadding + child.getMeasuredHeight() +
750 ViewCompat.getMeasuredState(child));
766 final View child = getChildAt(i);
767 if (ViewCompat.getFitsSystemWindows(child)) {
768 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
773 insets = b.onApplyWindowInsets(this, child, insets);
786 * Called to lay out each individual child view unless a
788 * delegate child measurement to this method.
790 * @param child child view to lay out
795 public void onLayoutChild(View child, int layoutDirection) {
796 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
802 layoutChildWithAnchor(child, lp.mAnchorView, layoutDirection);
804 layoutChildWithKeyline(child, lp.keyline, layoutDirection);
806 layoutChild(child, layoutDirection);
815 final View child = mDependencySortedChildren.get(i);
816 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
819 if (behavior == null || !behavior.onLayoutChild(this, child, layoutDirection)) {
820 onLayoutChild(child, layoutDirection);
838 * Mark the last known child position rect for the given child view.
839 * This will be used when checking if a child view's position has changed between frames.
844 * @param child child view to set for
847 void recordLastChildRect(View child, Rect r) {
848 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
853 * Get the last known child rect recorded by
856 * @param child child view to retrieve from
859 void getLastChildRect(View child, Rect out) {
860 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
865 * Get the position rect for the given child. If the child has currently requested layout
868 * @param child child view to check
873 void getChildRect(View child, boolean transform, Rect out) {
874 if (child.isLayoutRequested() || child.getVisibility() == View.GONE) {
879 getDescendantRect(child, out);
881 out.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
886 * Calculate the desired child rect relative to an anchor rect, respecting both
889 * @param child child view to calculate a rect for
894 void getDesiredAnchoredChildRect(View child, int layoutDirection, Rect anchorRect, Rect out) {
895 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
907 final int childWidth = child.getMeasuredWidth();
908 final int childHeight = child.getMeasuredHeight();
913 // Align to the anchor. This puts us in an assumed right/bottom child view gravity.
915 // the child size below.
942 // Offset by the child view's gravity itself. The above assumed right/bottom gravity.
984 * CORE ASSUMPTION: anchor has been laid out by the time this is called for a given child view.
986 * @param child child to lay out
987 * @param anchor view to anchor child relative to; already laid out.
990 private void layoutChildWithAnchor(View child, View anchor, int layoutDirection) {
991 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
996 getDesiredAnchoredChildRect(child, layoutDirection, anchorRect, childRect);
998 child.layout(childRect.left, childRect.top, childRect.right, childRect.bottom);
1002 * Lay out a child view with respect to a keyline.
1005 * the CoordinatorLayout. The child's gravity will affect how it is positioned with
1008 * @param child child to lay out
1012 private void layoutChildWithKeyline(View child, int keyline, int layoutDirection) {
1013 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1021 final int childWidth = child.getMeasuredWidth();
1022 final int childHeight = child.getMeasuredHeight();
1065 child.layout(left, top, left + childWidth, top + childHeight);
1069 * Lay out a child view with no special handling. This will position the child as
1072 * @param child child view to lay out
1075 private void layoutChild(View child, int layoutDirection) {
1076 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1084 && !ViewCompat.getFitsSystemWindows(child)) {
1085 // If we're set to handle insets but this child isn't, then it has been measured as
1094 GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(),
1095 child.getMeasuredHeight(), parent, out, layoutDirection);
1096 child.layout(out.left, out.top, out.right, out.bottom);
1124 protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
1125 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1126 if (lp.mBehavior != null && lp.mBehavior.getScrimOpacity(this, child) > 0.f) {
1130 mScrimPaint.setColor(lp.mBehavior.getScrimColor(this, child));
1136 return super.drawChild(canvas, child, drawingTime);
1142 * Usually run as part of the pre-draw step when at least one child view has a reported
1160 final View child = mDependencySortedChildren.get(i);
1161 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1163 // Check child views before for anchor
1168 offsetChildToAnchor(child, layoutDirection);
1175 getLastChildRect(child, oldRect);
1176 getChildRect(child, true, newRect);
1180 recordLastChildRect(child, newRect);
1188 if (b != null && b.layoutDependsOn(this, checkChild, child)) {
1196 final boolean handled = b.onDependentViewChanged(this, checkChild, child);
1212 final View child = mDependencySortedChildren.get(i);
1213 if (child == view) {
1220 child.getLayoutParams();
1222 if (b != null && lp.dependsOn(this, child, view)) {
1223 b.onDependentViewRemoved(this, child, view);
1243 final View child = mDependencySortedChildren.get(i);
1244 if (child == view) {
1251 child.getLayoutParams();
1253 if (b != null && lp.dependsOn(this, child, view)) {
1254 b.onDependentViewChanged(this, child, view);
1264 * @param child the view to find dependencies for.
1266 * @return the list of views which {@code child} depends on.
1268 public List<View> getDependencies(View child) {
1271 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1278 if (other == child) {
1281 if (lp.dependsOn(this, child, other)) {
1296 final View child = getChildAt(i);
1297 if (hasDependencies(child)) {
1313 * Check if the given child has any layout dependencies on other child views.
1315 boolean hasDependencies(View child) {
1316 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1324 if (other == child) {
1327 if (lp.dependsOn(this, child, other)) {
1368 * Adjust the child left, top, right, bottom rect to the correct anchor view position,
1371 * Note that child translation properties are ignored in this process, allowing children
1373 * the child will be offset to match the anchor's translated position.
1375 void offsetChildToAnchor(View child, int layoutDirection) {
1376 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1383 getChildRect(child, false, childRect);
1384 getDesiredAnchoredChildRect(child, layoutDirection, anchorRect, desiredChildRect);
1390 child.offsetLeftAndRight(dx);
1393 child.offsetTopAndBottom(dy);
1397 // If we have needed to move, make sure to notify the child's Behavior
1400 b.onDependentViewChanged(this, child, lp.mAnchorView);
1408 * of the given direct child view.
1410 * @param child child view to test
1413 * @return true if the point is within the child view's bounds, false otherwise
1415 public boolean isPointInChildBounds(View child, int x, int y) {
1417 getDescendantRect(child, r);
1425 * @param first first child view to test
1426 * @param second second child view to test
1467 public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
1476 final boolean accepted = viewBehavior.onStartNestedScroll(this, view, child, target,
1488 public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes) {
1489 mNestedScrollingParentHelper.onNestedScrollAccepted(child, target, nestedScrollAxes);
1490 mNestedScrollingDirectChild = child;
1503 viewBehavior.onNestedScrollAccepted(this, view, child, target, nestedScrollAxes);
1646 * Sorts child views with higher Z values to the beginning of a collection.
1666 * when used as a direct child of an {@link CoordinatorLayout}. The default behavior
1677 * Interaction behavior plugin for child views of {@link CoordinatorLayout}.
1679 * <p>A Behavior implements one or more interactions that a user can take on a child view.
1695 * appear on the child view tag.
1704 * Respond to CoordinatorLayout touch events before they are dispatched to child views.
1707 * intercept the rest of the event stream to take an action on its associated child view.
1717 * @param child the child view associated with this Behavior
1722 public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev) {
1731 * manipulate its child views. For example, a Behavior may allow a user to drag a
1736 * @param child the child view associated with this Behavior
1741 public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev) {
1746 * Supply a scrim color that will be painted behind the associated child view.
1754 * @param parent the parent view of the given child
1755 * @param child the child view above the scrim
1760 public int getScrimColor(CoordinatorLayout parent, V child) {
1765 * Determine the current opacity of the scrim behind a given child view
1773 * @param parent the parent view of the given child
1774 * @param child the child view above the scrim
1777 public float getScrimOpacity(CoordinatorLayout parent, V child) {
1782 * Determine whether interaction with views behind the given child in the child order
1788 * @param parent the parent view of the given child
1789 * @param child the child view to test
1793 public boolean blocksInteractionBelow(CoordinatorLayout parent, V child) {
1794 return getScrimOpacity(parent, child) > 0.f;
1798 * Determine whether the supplied child view has another specific sibling view as a
1802 * returns true for a given child and dependency view pair, the parent CoordinatorLayout
1805 * <li>Always lay out this child after the dependent child is laid out, regardless
1806 * of child order.</li>
1811 * @param parent the parent view of the given child
1812 * @param child the child view to test
1813 * @param dependency the proposed dependency of child
1814 * @return true if child's layout depends on the proposed dependency's layout,
1819 public boolean layoutDependsOn(CoordinatorLayout parent, V child, View dependency) {
1824 * Respond to a change in a child's dependent view
1828 * the child view in response.</p>
1832 * if {@code child} has set another view as it's anchor.</p>
1834 * <p>Note that if a Behavior changes the layout of a child via this method, it should
1838 * the layout of each child view will always happen in dependency order.</p>
1840 * <p>If the Behavior changes the child view's size or position, it should return true.
1843 * @param parent the parent view of the given child
1844 * @param child the child view to manipulate
1846 * @return true if the Behavior changed the child view's size or position, false otherwise
1848 public boolean onDependentViewChanged(CoordinatorLayout parent, V child, View dependency) {
1853 * Respond to a child's dependent view being removed.
1856 * A Behavior may use this method to appropriately update the child view in response.</p>
1860 * if {@code child} has set another view as it's anchor.</p>
1862 * @param parent the parent view of the given child
1863 * @param child the child view to manipulate
1866 public void onDependentViewRemoved(CoordinatorLayout parent, V child, View dependency) {
1870 * Determine whether the given child view should be considered dirty.
1873 * the Behavior should report a child view as dirty. This will prompt the CoordinatorLayout
1876 * @param parent the parent view of the given child
1877 * @param child the child view to check
1878 * @return true if child is dirty
1880 public boolean isDirty(CoordinatorLayout parent, V child) {
1885 * Called when the parent CoordinatorLayout is about to measure the given child view.
1887 * <p>This method can be used to perform custom or modified measurement of a child view
1888 * in place of the default child measurement behavior. The Behavior's implementation
1894 * @param child the child to measure
1901 * @return true if the Behavior measured the child view, false if the CoordinatorLayout
1904 public boolean onMeasureChild(CoordinatorLayout parent, V child,
1911 * Called when the parent CoordinatorLayout is about the lay out the given child view.
1913 * <p>This method can be used to perform custom or modified layout of a child view
1914 * in place of the default child layout behavior. The Behavior's implementation can
1927 * @param child child view to lay out
1931 * @return true if the Behavior performed layout of the child view, false to request
1934 public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) {
1938 // Utility methods for accessing child-specific, behavior-modifiable properties.
1941 * Associate a Behavior-specific tag object with the given child view.
1942 * This object will be stored with the child view's LayoutParams.
1944 * @param child child view to set tag with
1947 public static void setTag(View child, Object tag) {
1948 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1953 * Get the behavior-specific tag object with the given child view.
1954 * This object is stored with the child view's LayoutParams.
1956 * @param child child view to get tag with
1959 public static Object getTag(View child) {
1960 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
1968 * <p>Any Behavior associated with any direct child of the CoordinatorLayout may respond
1975 * @param child the child view of the CoordinatorLayout this Behavior is associated with
1976 * @param directTargetChild the child view of the CoordinatorLayout that either is or
1987 V child, View directTargetChild, View target, int nestedScrollAxes) {
1994 * <p>Any Behavior associated with any direct child of the CoordinatorLayout may elect
2001 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2002 * @param directTargetChild the child view of the CoordinatorLayout that either is or
2011 public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child,
2019 * <p>Any Behavior associated with any direct child of the CoordinatorLayout may elect
2030 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2036 public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
2044 * <p>Any Behavior associated with the direct child of the CoordinatorLayout may elect
2050 * nested scrolling child, with both consumed and unconsumed components of the scroll
2057 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2068 public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target,
2077 * <p>Any Behavior associated with the direct child of the CoordinatorLayout may elect
2083 * by the nested scrolling child, before the nested scrolling child has consumed the scroll
2091 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2101 public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target,
2107 * Called when a nested scrolling child is starting a fling or an action that would
2110 * <p>Any Behavior associated with the direct child of the CoordinatorLayout may elect
2115 * <p><code>onNestedFling</code> is called when the current nested scrolling child view
2116 * detects the proper conditions for a fling. It reports if the child itself consumed
2117 * the fling. If it did not, the child is expected to show some sort of overscroll
2118 * indication. This method should return true if it consumes the fling, so that a child
2124 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2128 * @param consumed true if the nested child view consumed the fling
2133 public boolean onNestedFling(CoordinatorLayout coordinatorLayout, V child, View target,
2139 * Called when a nested scrolling child is about to start a fling.
2141 * <p>Any Behavior associated with the direct child of the CoordinatorLayout may elect
2146 * <p><code>onNestedPreFling</code> is called when the current nested scrolling child view
2149 * Behavior returns true, the fling should not be acted upon by the child.</p>
2153 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2161 public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target,
2169 * <p>Any Behavior associated with the direct child of the CoordinatorLayout may elect
2175 * @param child the child view of the CoordinatorLayout this Behavior is associated with
2181 V child, WindowInsetsCompat insets) {
2191 * @param child child view to restore from
2197 public void onRestoreInstanceState(CoordinatorLayout parent, V child, Parcelable state) {
2211 * @param child child view to restore from
2219 public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child) {
2225 * Parameters describing the desired layout for a child of a {@link CoordinatorLayout}.
2229 * A {@link Behavior} that the child view should obey.
2236 * A {@link Gravity} value describing how this child view should lay out.
2238 * how this child view should be positioned relative to its anchored position.
2243 * A {@link Gravity} value describing which edge of a child view's
2244 * {@link #getAnchorId() anchor} view the child should position itself relative to.
2250 * child should align relative to. If an {@link #setAnchorId(int) anchor} is present the
2257 * this child should position relative to.
2329 * the child view this LayoutParams belongs to. It may not be the child view with
2341 * Get the behavior governing the layout and interaction of the child view within
2351 * Set the behavior governing the layout and interaction of the child view within
2368 * Set the last known position rect for this child view
2376 * Get the last known position rect for this child view.
2393 * below the associated child since the touch behavior tracking was last
2406 * Check if the associated Behavior wants to block interaction below the given child
2407 * view. The given child view should be the child this LayoutParams is associated with.
2413 * @param child the child view this LayoutParams is associated with
2414 * @return true to block interaction below the given child
2416 boolean isBlockingInteractionBelow(CoordinatorLayout parent, View child) {
2422 ? mBehavior.blocksInteractionBelow(parent, child)
2462 * Check if an associated child view depends on another child view of the CoordinatorLayout.
2465 * @param child the child to check
2467 * @return true if child depends on dependency
2469 boolean dependsOn(CoordinatorLayout parent, View child, View dependency) {
2471 || (mBehavior != null && mBehavior.layoutDependsOn(parent, child, dependency));
2475 * Invalidate the cached anchor view and direct child ancestor of that anchor.
2489 * @param forChild the child this LayoutParams is associated with
2506 * Check if the child associated with this LayoutParams is currently considered
2507 * "dirty" and needs to be updated. A Behavior should consider a child dirty
2512 * @param child the child view associated with this LayoutParams
2513 * @return true if this child view should be considered dirty
2515 boolean isDirty(CoordinatorLayout parent, View child) {
2516 return mBehavior != null && mBehavior.isDirty(parent, child);
2520 * Determine the anchor view for the child view this LayoutParams is assigned to.
2565 * a descendant of the expected parent view, it is not the child this LayoutParams
2600 public void onChildViewAdded(View parent, View child) {
2602 mOnHierarchyChangeListener.onChildViewAdded(parent, child);
2607 public void onChildViewRemoved(View parent, View child) {
2608 dispatchDependentViewRemoved(child);
2611 mOnHierarchyChangeListener.onChildViewRemoved(parent, child);
2629 final View child = getChildAt(i);
2630 final int childId = child.getId();
2631 final LayoutParams lp = getResolvedLayoutParams(child);
2637 b.onRestoreInstanceState(this, child, savedState);
2649 final View child = getChildAt(i);
2650 final int childId = child.getId();
2651 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
2655 // If the child has an ID and a Behavior, let it save some state...
2656 Parcelable state = b.onSaveInstanceState(this, child);