Пример #1
0
		public override bool requestChildRectangleOnScreen(android.view.View child, android.graphics.Rect
			 rectangle, bool immediate)
		{
			// offset into coordinate space of this scroll view
			rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY
				());
			return scrollToChildRect(rectangle, immediate);
		}
Пример #2
0
		/// <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);
			}
		}
Пример #3
0
		/// <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
				);
		}
Пример #4
0
		/// <summary>
		/// Add a view as a child and make sure it is measured (if necessary) and
		/// positioned properly.
		/// </summary>
		/// <remarks>
		/// Add a view as a child and make sure it is measured (if necessary) and
		/// positioned properly.
		/// </remarks>
		/// <param name="child">The view to add</param>
		/// <param name="position">The position of the view</param>
		/// <param name="y">The y position relative to which this view will be positioned</param>
		/// <param name="flow">
		/// if true, align top edge to y. If false, align bottom edge
		/// to y.
		/// </param>
		/// <param name="childrenLeft">Left edge where children should be positioned</param>
		/// <param name="selected">Is this position selected?</param>
		/// <param name="recycled">
		/// Has this view been pulled from the recycle bin? If so it
		/// does not need to be remeasured.
		/// </param>
		/// <param name="where">Where to add the item in the list</param>
		private void setupChild(android.view.View child, int position, int y, bool flow, 
			int childrenLeft, bool selected, bool recycled, int where)
		{
			bool isSelected_1 = selected && shouldShowSelector();
			bool updateChildSelected = isSelected_1 != child.isSelected();
			int mode = mTouchMode;
			bool isPressed_1 = mode > TOUCH_MODE_DOWN && mode < TOUCH_MODE_SCROLL && mMotionPosition
				 == position;
			bool updateChildPressed = isPressed_1 != child.isPressed();
			bool needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested(
				);
			// Respect layout params that are already in the view. Otherwise make
			// some up...
			android.widget.AbsListView.LayoutParams p = (android.widget.AbsListView.LayoutParams
				)child.getLayoutParams();
			if (p == null)
			{
				p = new android.widget.AbsListView.LayoutParams(android.view.ViewGroup.LayoutParams
					.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0);
			}
			p.viewType = mAdapter.getItemViewType(position);
			if (recycled && !p.forceAdd)
			{
				attachViewToParent(child, where, p);
			}
			else
			{
				p.forceAdd = false;
				addViewInLayout(child, where, p, true);
			}
			if (updateChildSelected)
			{
				child.setSelected(isSelected_1);
				if (isSelected_1)
				{
					requestFocus();
				}
			}
			if (updateChildPressed)
			{
				child.setPressed(isPressed_1);
			}
			if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null)
			{
				if (child is android.widget.Checkable)
				{
					((android.widget.Checkable)child).setChecked(mCheckStates.get(position));
				}
				else
				{
					if (getContext().getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES
						.HONEYCOMB)
					{
						child.setActivated(mCheckStates.get(position));
					}
				}
			}
			if (needToMeasure)
			{
				int childHeightSpec = android.view.ViewGroup.getChildMeasureSpec(android.view.View
					.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED), 0, p
					.height);
				int childWidthSpec = android.view.ViewGroup.getChildMeasureSpec(android.view.View
					.MeasureSpec.makeMeasureSpec(mColumnWidth, android.view.View.MeasureSpec.EXACTLY
					), 0, p.width);
				child.measure(childWidthSpec, childHeightSpec);
			}
			else
			{
				cleanupLayoutState(child);
			}
			int w = child.getMeasuredWidth();
			int h = child.getMeasuredHeight();
			int childLeft;
			int childTop = flow ? y : y - h;
			int layoutDirection = getResolvedLayoutDirection();
			int absoluteGravity = android.view.Gravity.getAbsoluteGravity(mGravity, layoutDirection
				);
			switch (absoluteGravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK)
			{
				case android.view.Gravity.LEFT:
				{
					childLeft = childrenLeft;
					break;
				}

				case android.view.Gravity.CENTER_HORIZONTAL:
				{
					childLeft = childrenLeft + ((mColumnWidth - w) / 2);
					break;
				}

				case android.view.Gravity.RIGHT:
				{
					childLeft = childrenLeft + mColumnWidth - w;
					break;
				}

				default:
				{
					childLeft = childrenLeft;
					break;
				}
			}
			if (needToMeasure)
			{
				int childRight = childLeft + w;
				int childBottom = childTop + h;
				child.layout(childLeft, childTop, childRight, childBottom);
			}
			else
			{
				child.offsetLeftAndRight(childLeft - child.getLeft());
				child.offsetTopAndBottom(childTop - child.getTop());
			}
			if (mCachingStarted)
			{
				child.setDrawingCacheEnabled(true);
			}
			if (recycled && (((android.widget.AbsListView.LayoutParams)child.getLayoutParams(
				)).scrappedFromPosition) != position)
			{
				child.jumpDrawablesToCurrentState();
			}
		}