当前位置: 首页>>代码示例>>Java>>正文


Java View.getDrawingRect方法代码示例

本文整理汇总了Java中android.view.View.getDrawingRect方法的典型用法代码示例。如果您正苦于以下问题:Java View.getDrawingRect方法的具体用法?Java View.getDrawingRect怎么用?Java View.getDrawingRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.getDrawingRect方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateClippingRect

import android.view.View; //导入方法依赖的package包/类
/**
 * Can be used by view that support {@code removeClippedSubviews} property to calculate area that
 * given {@param view} should be clipped to based on the clipping rectangle of it's parent in
 * case when parent is also set to clip it's children.
 *
 * @param view view that we want to calculate clipping rect for
 * @param outputRect where the calculated rectangle will be written
 */
public static void calculateClippingRect(View view, Rect outputRect) {
  ViewParent parent = view.getParent();
  if (parent == null) {
    outputRect.setEmpty();
    return;
  } else if (parent instanceof ReactClippingViewGroup) {
    ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent;
    if (clippingViewGroup.getRemoveClippedSubviews()) {
      clippingViewGroup.getClippingRect(sHelperRect);
      // Intersect the view with the parent's rectangle
      // This will result in the overlap with coordinates in the parent space
      if (!sHelperRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
        outputRect.setEmpty();
        return;
      }
      // Now we move the coordinates to the View's coordinate space
      sHelperRect.offset(-view.getLeft(), -view.getTop());
      sHelperRect.offset(view.getScrollX(), view.getScrollY());
      outputRect.set(sHelperRect);
      return;
    }
  }
  view.getDrawingRect(outputRect);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:33,代码来源:ReactClippingViewGroupHelper.java

示例2: amountToScrollToNewFocus

import android.view.View; //导入方法依赖的package包/类
/**
 * Determine how much we need to scroll in order to get newFocus in view.
 * 
 * @param direction
 *            either {@link android.view.View#FOCUS_UP} or
 *            {@link android.view.View#FOCUS_DOWN}.
 * @param newFocus
 *            The view that would take focus.
 * @param positionOfNewFocus
 *            The position of the list item containing newFocus
 * @return The amount to scroll. Note: this is always positive! Direction
 *         needs to be taken into account when actually scrolling.
 */
private int amountToScrollToNewFocus(int direction, View newFocus, int positionOfNewFocus) {
	int amountToScroll = 0;
	newFocus.getDrawingRect(mTempRect);
	offsetDescendantRectToMyCoords(newFocus, mTempRect);
	if (direction == View.FOCUS_UP) {
		if (mTempRect.left < mListPadding.left) {
			amountToScroll = mListPadding.left - mTempRect.left;
			if (positionOfNewFocus > 0) {
				amountToScroll += getArrowScrollPreviewLength();
			}
		}
	} else {
		final int listRight = getWidth() - mListPadding.right;
		if (mTempRect.bottom > listRight) {
			amountToScroll = mTempRect.right - listRight;
			if (positionOfNewFocus < mItemCount - 1) {
				amountToScroll += getArrowScrollPreviewLength();
			}
		}
	}
	return amountToScroll;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:36,代码来源:HListView.java

示例3: onSizeChanged

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    View currentFocused = findFocus();
    if (null == currentFocused || this == currentFocused)
        return;

    // If the currently-focused view was visible on the screen when the
    // screen was at the old height, then scroll the screen to make that
    // view visible with the new screen height.
    currentFocused.getDrawingRect(mTempRect);
    offsetDescendantRectToMyCoords(currentFocused, mTempRect);
    int scrollDeltaX = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
    int scrollDeltaY = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
    doScroll(scrollDeltaX, scrollDeltaY);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:18,代码来源:TwoDScrollView.java

示例4: requestChildFocus

import android.view.View; //导入方法依赖的package包/类
@Override
public void requestChildFocus(View child, View focused) {
    super.requestChildFocus(child, focused);
    if (child != null) {
        Rect r = new Rect();
        child.getDrawingRect(r);
        requestRectangleOnScreen(r);
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:10,代码来源:ShortcutAndWidgetContainer.java

示例5: setAnchor

import android.view.View; //导入方法依赖的package包/类
public void setAnchor(View view) {
    Rect rect = new Rect();
    //get view's visible bounds
    view.getDrawingRect(rect);
    //calculate the relative coordinates to parent
    offsetDescendantRectToMyCoords(view, rect);
    if (orientation == Orientation.HORIZONTAL) {
        holePosition = rect.left - holeRadius;
    } else {
        holePosition = rect.bottom + holeRadius;
    }
    postInvalidate();
}
 
开发者ID:santalu,项目名称:ticket-view,代码行数:14,代码来源:TicketView.java

示例6: onFocusChanged

import android.view.View; //导入方法依赖的package包/类
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    ListAdapter adapter = this.mAdapter;
    int closetChildIndex = -1;
    int closestChildLeft = 0;
    if (!(adapter == null || !gainFocus || previouslyFocusedRect == null)) {
        previouslyFocusedRect.offset(getScrollX(), getScrollY());
        if (adapter.getCount() < getChildCount() + this.mFirstPosition) {
            this.mLayoutMode = 0;
            layoutChildren();
        }
        Rect otherRect = this.mTempRect;
        int minDistance = Integer.MAX_VALUE;
        int childCount = getChildCount();
        int firstPosition = this.mFirstPosition;
        for (int i = 0; i < childCount; i++) {
            if (adapter.isEnabled(firstPosition + i)) {
                View other = getChildAt(i);
                other.getDrawingRect(otherRect);
                offsetDescendantRectToMyCoords(other, otherRect);
                int distance = AbsHListView.getDistance(previouslyFocusedRect, otherRect, direction);
                if (distance < minDistance) {
                    minDistance = distance;
                    closetChildIndex = i;
                    closestChildLeft = other.getLeft();
                }
            }
        }
    }
    if (closetChildIndex >= 0) {
        setSelectionFromLeft(this.mFirstPosition + closetChildIndex, closestChildLeft);
    } else {
        requestLayout();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:36,代码来源:HListView.java

示例7: arrowScroll

import android.view.View; //导入方法依赖的package包/类
public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;
    }
    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    int maxJump = getMaxScrollAmount();
    if (nextFocused == null || !isWithinDeltaOfScreen(nextFocused, maxJump, getHeight())) {
        int scrollDelta = maxJump;
        if (direction == 33 && getScrollY() < scrollDelta) {
            scrollDelta = getScrollY();
        } else if (direction == 130 && getChildCount() > 0) {
            int daBottom = getChildAt(0).getBottom();
            int screenBottom = (getScrollY() + getHeight()) - getPaddingBottom();
            if (daBottom - screenBottom < maxJump) {
                scrollDelta = daBottom - screenBottom;
            }
        }
        if (scrollDelta == 0) {
            return false;
        }
        int i;
        if (direction == 130) {
            i = scrollDelta;
        } else {
            i = -scrollDelta;
        }
        doScrollY(i);
    } else {
        nextFocused.getDrawingRect(this.mTempRect);
        offsetDescendantRectToMyCoords(nextFocused, this.mTempRect);
        doScrollY(computeScrollDeltaToGetChildRectOnScreen(this.mTempRect));
        nextFocused.requestFocus(direction);
    }
    if (currentFocused != null && currentFocused.isFocused() && isOffScreen(currentFocused)) {
        int descendantFocusability = getDescendantFocusability();
        setDescendantFocusability(131072);
        requestFocus();
        setDescendantFocusability(descendantFocusability);
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:43,代码来源:NestedScrollView.java

示例8: scrollToChild

import android.view.View; //导入方法依赖的package包/类
private void scrollToChild(View child) {
    child.getDrawingRect(this.mTempRect);
    offsetDescendantRectToMyCoords(child, this.mTempRect);
    int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(this.mTempRect);
    if (scrollDelta != 0) {
        scrollBy(0, scrollDelta);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:NestedScrollView.java

示例9: onSizeChanged

import android.view.View; //导入方法依赖的package包/类
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    View currentFocused = findFocus();
    if (currentFocused != null && this != currentFocused && isWithinDeltaOfScreen(currentFocused, 0, oldh)) {
        currentFocused.getDrawingRect(this.mTempRect);
        offsetDescendantRectToMyCoords(currentFocused, this.mTempRect);
        doScrollY(computeScrollDeltaToGetChildRectOnScreen(this.mTempRect));
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:NestedScrollView.java

示例10: scrollToChild

import android.view.View; //导入方法依赖的package包/类
/**
  * Scrolls the view to the given child.
  *
  * @param child the View to scroll to
  */
 private void scrollToChild(View child) {
     child.getDrawingRect(mTempRect);
/* Offset from child's local coordinates to TwoDScrollView coordinates */
     offsetDescendantRectToMyCoords(child, mTempRect);
     int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
     if (scrollDelta != 0) {
         scrollBy(0, scrollDelta);
     }
 }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:TwoDScrollView.java

示例11: isWithinDeltaOfScreen

import android.view.View; //导入方法依赖的package包/类
private boolean isWithinDeltaOfScreen(View descendant, int delta, int height) {
    descendant.getDrawingRect(this.mTempRect);
    offsetDescendantRectToMyCoords(descendant, this.mTempRect);
    return this.mTempRect.bottom + delta >= getScrollY() && this.mTempRect.top - delta <= getScrollY() + height;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:6,代码来源:NestedScrollView.java

示例12: onFocusChanged

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
	super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);

	final ListAdapter adapter = mAdapter;
	int closetChildIndex = -1;
	int closestChildLeft = 0;
	if (adapter != null && gainFocus && previouslyFocusedRect != null) {
		previouslyFocusedRect.offset(getScrollX(), getScrollY());

		// Don't cache the result of getChildCount or mFirstPosition here,
		// it could change in layoutChildren.
		if (adapter.getCount() < getChildCount() + mFirstPosition) {
			mLayoutMode = LAYOUT_NORMAL;
			layoutChildren();
		}

		// figure out which item should be selected based on previously
		// focused rect
		Rect otherRect = mTempRect;
		int minDistance = Integer.MAX_VALUE;
		final int childCount = getChildCount();
		final int firstPosition = mFirstPosition;

		for (int i = 0; i < childCount; i++) {
			// only consider selectable views
			if (!adapter.isEnabled(firstPosition + i)) {
				continue;
			}

			View other = getChildAt(i);
			other.getDrawingRect(otherRect);
			offsetDescendantRectToMyCoords(other, otherRect);
			int distance = getDistance(previouslyFocusedRect, otherRect, direction);

			if (distance < minDistance) {
				minDistance = distance;
				closetChildIndex = i;
				closestChildLeft = other.getLeft();
			}
		}
	}

	if (closetChildIndex >= 0) {
		setSelectionFromLeft(closetChildIndex + mFirstPosition, closestChildLeft);
	} else {
		requestLayout();
	}
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:50,代码来源:HListView.java

示例13: onInterceptTouchEvent

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (mDragListener != null || mDropListener != null) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                int x = (int) ev.getX();
                int y = (int) ev.getY();
                int itemnum = pointToPosition(x, y);
                if (itemnum == AdapterView.INVALID_POSITION) {
                    break;
                }
                ViewGroup item = (ViewGroup) getChildAt(itemnum - getFirstVisiblePosition());
                mDragPoint = y - item.getTop();
                mCoordOffset = ((int) ev.getRawY()) - y;
                View dragger = item.findViewById(R.id.grabber);
                Rect r = mTempRect;
                dragger.getDrawingRect(r);
                if (shouldStartDragging(x, r.width())) {
                    // Fix x position while dragging
                    int[] itemPos = new int[2];
                    item.getLocationOnScreen(itemPos);

                    item.setDrawingCacheEnabled(true);
                    // Create a copy of the drawing cache so that it does
                    // not get recycled
                    // by the framework when the list tries to clean up
                    // memory
                    Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
                    startDragging(bitmap, itemPos[0], y);
                    mDragPos = itemnum;
                    mFirstDragPos = mDragPos;
                    mHeight = getHeight();
                    int touchSlop = mTouchSlop;
                    mUpperBound = Math.min(y - touchSlop, mHeight / 3);
                    mLowerBound = Math.max(y + touchSlop, mHeight * 2 / 3);
                    return false;
                }
                stopDragging();
                break;
        }
    }
    return super.onInterceptTouchEvent(ev);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:44,代码来源:TouchInterceptor.java


注:本文中的android.view.View.getDrawingRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。