/// <summary> /// <p> /// Finds the next focusable component that fits in this View's bounds /// (excluding fading edges) pretending that this View's top is located at /// the parameter top. /// </summary> /// <remarks> /// <p> /// Finds the next focusable component that fits in this View's bounds /// (excluding fading edges) pretending that this View's top is located at /// the parameter top. /// </p> /// </remarks> /// <param name="topFocus"> /// look for a candidate at the top of the bounds if topFocus is true, /// or at the bottom of the bounds if topFocus is false /// </param> /// <param name="top"> /// the top offset of the bounds in which a focusable must be /// found (the fading edge is assumed to start at this position) /// </param> /// <param name="preferredFocusable"> /// the View that has highest priority and will be /// returned if it is within my bounds (null is valid) /// </param> /// <returns>the next focusable component in the bounds or null if none can be found</returns> private android.view.View findFocusableViewInMyBounds(bool topFocus, int top, android.view.View preferredFocusable) { int fadingEdgeLength = getVerticalFadingEdgeLength() / 2; int topWithoutFadingEdge = top + fadingEdgeLength; int bottomWithoutFadingEdge = top + getHeight() - fadingEdgeLength; if ((preferredFocusable != null) && (preferredFocusable.getTop() < bottomWithoutFadingEdge ) && (preferredFocusable.getBottom() > topWithoutFadingEdge)) { return preferredFocusable; } return findFocusableViewInBounds(topFocus, topWithoutFadingEdge, bottomWithoutFadingEdge ); }
/// <summary> /// Move all views upwards so the selected row does not interesect the top /// fading edge (if necessary). /// </summary> /// <remarks> /// Move all views upwards so the selected row does not interesect the top /// fading edge (if necessary). /// </remarks> /// <param name="childInSelectedRow">A child in the row that contains the selection</param> /// <param name="topSelectionPixel">The topmost pixel we can draw the selection into</param> /// <param name="bottomSelectionPixel"> /// The bottommost pixel we can draw the /// selection into /// </param> private void adjustForTopFadingEdge(android.view.View childInSelectedRow, int topSelectionPixel , int bottomSelectionPixel) { // Some of the newly selected item extends above the top of the list if (childInSelectedRow.getTop() < topSelectionPixel) { // Find space required to bring the top of the selected item // fully into view int spaceAbove = topSelectionPixel - childInSelectedRow.getTop(); // Find space available below the selection into which we can // scroll downwards int spaceBelow = bottomSelectionPixel - childInSelectedRow.getBottom(); int offset = System.Math.Min(spaceAbove, spaceBelow); // Now offset the selected item to get it into view offsetChildrenTopAndBottom(offset); } }