android.view.ViewGroup#getTop ( )源码实例Demo

下面列出了android.view.ViewGroup#getTop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: o2oa   文件: SwipeLayout.java
@Override
public boolean onDoubleTap(MotionEvent e) {
    if (mDoubleClickListener != null) {
        View target;
        ViewGroup bottom = getBottomView();
        ViewGroup surface = getSurfaceView();
        if (e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
                && e.getY() > bottom.getTop()
                && e.getY() < bottom.getBottom()) {
            target = bottom;
        } else {
            target = surface;
        }
        mDoubleClickListener.onDoubleClick(SwipeLayout.this,
                target == surface);
    }
    return true;
}
 
源代码2 项目: o2oa   文件: SwipeLayoutConv.java
/**
 * close surface
 *
 * @param smooth smoothly or not.
 * @param notify if notify all the listeners.
 */
public void close(boolean smooth, boolean notify) {
    ViewGroup surface = getSurfaceView();
    int dx, dy;
    if (smooth)
        mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(),
                getPaddingTop());
    else {
        Rect rect = computeSurfaceLayoutArea(false);
        dx = rect.left - surface.getLeft();
        dy = rect.top - surface.getTop();
        surface.layout(rect.left, rect.top, rect.right, rect.bottom);
        if (notify) {
            dispatchRevealEvent(rect.left, rect.top, rect.right,
                    rect.bottom);
            dispatchSwipeEvent(rect.left, rect.top, dx, dy);
        } else {
            safeBottomView();
        }
    }
    invalidate();
}
 
源代码3 项目: container   文件: PendIntentCompat.java
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) {
	int count = viewGroup.getChildCount();
	for (int i = 0; i < count; i++) {
		View v = viewGroup.getChildAt(i);
		if (v instanceof ViewGroup) {
			// linearlayout
			setIntentByViewGroup(remoteViews, (ViewGroup) v, list);
		} else if (v instanceof TextView) {
			// textview
			Rect rect = new Rect();
			v.getHitRect(rect);
			// height修正
			rect.top += viewGroup.getTop();
			rect.bottom += viewGroup.getTop();
			PendingIntent pendingIntent = findIntent(rect, list);
			if (pendingIntent != null) {
				remoteViews.setOnClickPendingIntent(v.getId(), pendingIntent);
			}
		}
	}
}
 
源代码4 项目: Trebuchet   文件: ClickShadowView.java
/**
 * Aligns the shadow with {@param view}
 * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
 */
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent) {
    float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
    float topShift = view.getTop() + viewParent.getTop() - getTop();
    int iconWidth = view.getRight() - view.getLeft();
    int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    float drawableWidth = view.getIcon().getBounds().width();

    setTranslationX(leftShift
            + viewParent.getTranslationX()
            + view.getCompoundPaddingLeft() * view.getScaleX()
            + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
            + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
    setTranslationY(topShift
            + viewParent.getTranslationY()
            + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
            + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
}
 
源代码5 项目: AutoLoadListView   文件: ZSwipeItem.java
public void close(boolean smooth, boolean notify) {
	ViewGroup surface = getSurfaceView();
	int dx, dy;
	if (smooth)
		mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(),
				getPaddingTop());
	else {
		Rect rect = computeSurfaceLayoutArea(false);
		dx = rect.left - surface.getLeft();
		dy = rect.top - surface.getTop();
		surface.layout(rect.left, rect.top, rect.right, rect.bottom);
		if (notify) {
			dispatchSwipeEvent(rect.left, rect.top, dx, dy);
		} else {
			safeBottomView();
		}
	}
	invalidate();
}
 
源代码6 项目: DongWeather   文件: DragListView.java
/**
     * 获取触点所在条目的位置
     * 获取选中条目的图片
     * 事件的拦截机制
     *
     * @param ev
     * @return
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
//识别动作
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
//获取触点的坐标
                int x = (int) ev.getX();
                int y = (int) ev.getY();
//这样就可以计算我按到哪个条目上了
                mStartPosition = mEndPosition = pointToPosition(x, y);
//判断触点是否在logo的区域
                ViewGroup itemView = (ViewGroup) getChildAt(mStartPosition - getFirstVisiblePosition());
//记录手指在条目中的相对Y坐标
                dragPoint = y - itemView.getTop();
//ListView在屏幕中的Y坐标
                dragOffset = (int) (ev.getRawY() - y);
//拖动的图标
                View dragger = itemView.findViewById(R.id.guide_shape_im); //有修改
//判断触点是否在logo区域
                if (dragger != null && x < dragger.getRight() + 10) {
//定义ListView的滚动条目
//上
                    upScroll = getHeight() / 3;
//下
                    downScroll = getHeight() * 2 / 3;
//获取选中的图片/截图
                    itemView.setDrawingCacheEnabled(true);
//获取截图
                    Bitmap bitMap = itemView.getDrawingCache();
//图片滚动
                    startDrag(bitMap, y);
                }
                break;
        }
//还会传递事件到子View
        return false;
    }
 
源代码7 项目: Field-Book   文件: DragSortListView.java
private void drawDivider(int expPosition, Canvas canvas) {
    final Drawable divider = getDivider();
    final int dividerHeight = getDividerHeight();

    if (divider != null && dividerHeight != 0) {
        final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                - getFirstVisiblePosition());
        if (expItem != null) {
            final int left = getPaddingLeft();
            final int right = getWidth() - getPaddingRight();
            final int top;
            final int bottom;

            final int childHeight = expItem.getChildAt(0).getHeight();

            if (expPosition > mSrcPos) {
                top = expItem.getTop() + childHeight;
                bottom = top + dividerHeight;
            } else {
                bottom = expItem.getBottom() - childHeight;
                top = bottom - dividerHeight;
            }

            // Have to clip to support ColorDrawable on <= Gingerbread
            canvas.save();
            canvas.clipRect(left, top, right, bottom);
            divider.setBounds(left, top, right, bottom);
            divider.draw(canvas);
            canvas.restore();
        }
    }
}
 
源代码8 项目: 365browser   文件: FocusAnimator.java
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
    ViewGroup parent = (ViewGroup) mLayout.getParent();
    if (mLayout.getParent() == null) return;

    // Scroll the parent to make the focused child visible.
    if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);

    // {@link View#requestChildFocus} fails to account for children changing their height, so
    // the scroll value may be past the actual maximum.
    int viewportHeight = parent.getBottom() - parent.getTop();
    int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
    if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
 
源代码9 项目: LaunchEnr   文件: ClickShadowView.java
/**
 * Aligns the shadow with {@param view}
 * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
 */
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
    float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
    float topShift = view.getTop() + viewParent.getTop() - getTop();
    int iconWidth = view.getRight() - view.getLeft();
    int iconHeight = view.getBottom() - view.getTop();
    int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    float drawableWidth = view.getIcon().getBounds().width();

    if (clipAgainstView != null) {
        // Set the bounds to clip against
        int[] coords = new int[] {0, 0};
        Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
                coords, false);
        int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
        int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
        setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
    } else {
        // Reset the clip bounds
        setClipBounds(null);
    }

    setTranslationX(leftShift
            + viewParent.getTranslationX()
            + view.getCompoundPaddingLeft() * view.getScaleX()
            + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
            + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
    setTranslationY(topShift
            + viewParent.getTranslationY()
            + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
            + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
}
 
源代码10 项目: Overchan-Android   文件: DragSortListView.java
private void drawDivider(int expPosition, Canvas canvas) {

        final Drawable divider = getDivider();
        final int dividerHeight = getDividerHeight();
        // Log.d("mobeta", "div="+divider+" divH="+dividerHeight);

        if (divider != null && dividerHeight != 0) {
            final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                    - getFirstVisiblePosition());
            if (expItem != null) {
                final int l = getPaddingLeft();
                final int r = getWidth() - getPaddingRight();
                final int t;
                final int b;

                final int childHeight = expItem.getChildAt(0).getHeight();

                if (expPosition > mSrcPos) {
                    t = expItem.getTop() + childHeight;
                    b = t + dividerHeight;
                } else {
                    b = expItem.getBottom() - childHeight;
                    t = b - dividerHeight;
                }
                // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);

                // Have to clip to support ColorDrawable on <= Gingerbread
                canvas.save();
                canvas.clipRect(l, t, r, b);
                divider.setBounds(l, t, r, b);
                divider.draw(canvas);
                canvas.restore();
            }
        }
    }
 
private void drawDivider(int expPosition, Canvas canvas) {

        final Drawable divider = getDivider();
        final int dividerHeight = getDividerHeight();
        // Log.d("mobeta", "div="+divider+" divH="+dividerHeight);

        if (divider != null && dividerHeight != 0) {
            final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                    - getFirstVisiblePosition());
            if (expItem != null) {
                final int l = getPaddingLeft();
                final int r = getWidth() - getPaddingRight();
                final int t;
                final int b;

                final int childHeight = expItem.getChildAt(0).getHeight();

                if (expPosition > mSrcPos) {
                    t = expItem.getTop() + childHeight;
                    b = t + dividerHeight;
                } else {
                    b = expItem.getBottom() - childHeight;
                    t = b - dividerHeight;
                }
                // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);

                // Have to clip to support ColorDrawable on <= Gingerbread
                canvas.save();
                canvas.clipRect(l, t, r, b);
                divider.setBounds(l, t, r, b);
                divider.draw(canvas);
                canvas.restore();
            }
        }
    }
 
源代码12 项目: android-kernel-tweaker   文件: DragSortListView.java
private void drawDivider(int expPosition, Canvas canvas) {

        final Drawable divider = getDivider();
        final int dividerHeight = getDividerHeight();
        // Log.d("mobeta", "div="+divider+" divH="+dividerHeight);

        if (divider != null && dividerHeight != 0) {
            final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                    - getFirstVisiblePosition());
            if (expItem != null) {
                final int l = getPaddingLeft();
                final int r = getWidth() - getPaddingRight();
                final int t;
                final int b;

                final int childHeight = expItem.getChildAt(0).getHeight();

                if (expPosition > mSrcPos) {
                    t = expItem.getTop() + childHeight;
                    b = t + dividerHeight;
                } else {
                    b = expItem.getBottom() - childHeight;
                    t = b - dividerHeight;
                }
                // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);

                // Have to clip to support ColorDrawable on <= Gingerbread
                canvas.save();
                canvas.clipRect(l, t, r, b);
                divider.setBounds(l, t, r, b);
                divider.draw(canvas);
                canvas.restore();
            }
        }
    }
 
源代码13 项目: UltimateAndroid   文件: CalendarGridView.java
@Override protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  final ViewGroup row = (ViewGroup) getChildAt(1);
  int top = row.getTop();
  int bottom = getBottom();
  // Left side border.
  final int left = row.getChildAt(0).getLeft() + getLeft();
  canvas.drawLine(left + FLOAT_FUDGE, top, left + FLOAT_FUDGE, bottom, dividerPaint);

  // Each cell's right-side border.
  for (int c = 0; c < 7; c++) {
    float x = left + row.getChildAt(c).getRight() - FLOAT_FUDGE;
    canvas.drawLine(x, top, x, bottom, dividerPaint);
  }
}
 
源代码14 项目: android-times-square   文件: CalendarGridView.java
@Override protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  final ViewGroup row = (ViewGroup) getChildAt(1);
  int top = row.getTop();
  int bottom = getBottom();
  // Left side border.
  final int left = row.getChildAt(0).getLeft() + getLeft();
  canvas.drawLine(left + FLOAT_FUDGE, top, left + FLOAT_FUDGE, bottom, dividerPaint);

  // Each cell's right-side border.
  for (int c = 0; c < 7; c++) {
    float x = left + row.getChildAt(c).getRight() - FLOAT_FUDGE;
    canvas.drawLine(x, top, x, bottom, dividerPaint);
  }
}
 
源代码15 项目: delion   文件: FocusAnimator.java
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
    ViewGroup parent = (ViewGroup) mLayout.getParent();
    if (mLayout.getParent() == null) return;

    // Scroll the parent to make the focused child visible.
    if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);

    // {@link View#requestChildFocus} fails to account for children changing their height, so
    // the scroll value may be past the actual maximum.
    int viewportHeight = parent.getBottom() - parent.getTop();
    int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
    if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
 
源代码16 项目: AndroidChromium   文件: FocusAnimator.java
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
    ViewGroup parent = (ViewGroup) mLayout.getParent();
    if (mLayout.getParent() == null) return;

    // Scroll the parent to make the focused child visible.
    if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);

    // {@link View#requestChildFocus} fails to account for children changing their height, so
    // the scroll value may be past the actual maximum.
    int viewportHeight = parent.getBottom() - parent.getTop();
    int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
    if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
 
源代码17 项目: mobile-manager-tool   文件: DragSortListView.java
private void drawDivider(int expPosition, Canvas canvas) {

        final Drawable divider = getDivider();
        final int dividerHeight = getDividerHeight();
        // Log.d("mobeta", "div="+divider+" divH="+dividerHeight);

        if (divider != null && dividerHeight != 0) {
            final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                    - getFirstVisiblePosition());
            if (expItem != null) {
                final int l = getPaddingLeft();
                final int r = getWidth() - getPaddingRight();
                final int t;
                final int b;

                final int childHeight = expItem.getChildAt(0).getHeight();

                if (expPosition > mSrcPos) {
                    t = expItem.getTop() + childHeight;
                    b = t + dividerHeight;
                } else {
                    b = expItem.getBottom() - childHeight;
                    t = b - dividerHeight;
                }
                // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);

                // Have to clip to support ColorDrawable on <= Gingerbread
                canvas.save();
                canvas.clipRect(l, t, r, b);
                divider.setBounds(l, t, r, b);
                divider.draw(canvas);
                canvas.restore();
            }
        }
    }
 
源代码18 项目: UltimateAndroid   文件: DragSortListView.java
private void drawDivider(int expPosition, Canvas canvas) {

        final Drawable divider = getDivider();
        final int dividerHeight = getDividerHeight();
        // Log.d("mobeta", "div="+divider+" divH="+dividerHeight);

        if (divider != null && dividerHeight != 0) {
            final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                    - getFirstVisiblePosition());
            if (expItem != null) {
                final int l = getPaddingLeft();
                final int r = getWidth() - getPaddingRight();
                final int t;
                final int b;

                final int childHeight = expItem.getChildAt(0).getHeight();

                if (expPosition > mSrcPos) {
                    t = expItem.getTop() + childHeight;
                    b = t + dividerHeight;
                } else {
                    b = expItem.getBottom() - childHeight;
                    t = b - dividerHeight;
                }
                // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);

                // Have to clip to support ColorDrawable on <= Gingerbread
                canvas.save();
                canvas.clipRect(l, t, r, b);
                divider.setBounds(l, t, r, b);
                divider.draw(canvas);
                canvas.restore();
            }
        }
    }
 
源代码19 项目: direct-select-android   文件: DSListView.java
@Override
public void onScroll(AbsListView listView, int firstVisible, int visibleItemCount, int totalItemCount) {
    if (!pickerInitialized || !selectorAnimationsEnabled) return;

    int selectorPosY = cellHeight * cellsBeforeSelector;
    int applyingRangeY = cellHeight;

    for (int i = 0; i < listView.getChildCount(); i++) {

        // Exclude elements that does not need to edit
        if (!(listView.getChildAt(i) instanceof FrameLayout))
            continue;

        ViewGroup itemRoot = (ViewGroup) listView.getChildAt(i);

        float deviation = 2f;
        if (itemRoot.getTop() > selectorPosY + applyingRangeY * deviation || itemRoot.getTop() < selectorPosY - applyingRangeY * deviation)
            continue;

        View cellContent = itemRoot.getChildAt(0);

        // Edit elements regarding to their position from selector
        float dy = Math.abs(itemRoot.getTop() - selectorPosY);
        if (!selectorAnimationCenterPivot) {
            cellContent.setPivotX(0);
            cellContent.setPivotY(cellContent.getHeight() / 2);
        }

        // Scale and "3d effect" for big scale factors on API>=LOLLIPOP
        if (dy <= applyingRangeY) {
            float k1 = 1 - (dy / applyingRangeY);
            float scale = 1 + scaleFactorDelta * k1;
            cellContent.setScaleX(scale);
            cellContent.setScaleY(scale);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                itemRoot.setZ((dy <= applyingRangeY / 2) ? 2 : 1);

        } else {
            cellContent.setScaleX(1f);
            cellContent.setScaleY(1f);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                itemRoot.setZ(0);
        }

    }
}
 
源代码20 项目: GravityBox   文件: TouchInterceptor.java
@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);
}
 
 方法所在类