android.view.View#getBottom ( )源码实例Demo

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

源代码1 项目: WanAndroid   文件: LMRecyclerView.java
/**
 * 滑动监听
 * @param recyclerView
 * @param dx
 * @param dy
 */
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    LayoutManager layoutManager = recyclerView.getLayoutManager();

    if (layoutManager instanceof LinearLayoutManager) {
        LinearLayoutManager linearLayout = (LinearLayoutManager) layoutManager;
        int mLastChildPosition = linearLayout.findLastVisibleItemPosition();
        int itemTotalCount = linearLayout.getItemCount();
        View lastChildView = linearLayout.getChildAt(linearLayout.getChildCount() - 1);
        int lastChildBottom = lastChildView.getBottom();
        int recyclerBottom = getBottom();
        if (mLastChildPosition == itemTotalCount - 1 && lastChildBottom == recyclerBottom) {
            if (isCanLoadMore && listener != null) {
                //业务代码
                listener.loadMore();
            }
        }
    }
}
 
源代码2 项目: libcommon   文件: TwoPanelViewGroup.java
private void onLayoutSelect2(final boolean changed, final int left, final int top, final int right, final int bottom) {
//		if (DEBUG) Log.v(TAG, "onLayoutSelect2:");
		final View ch1 = mFlipChildPos ? mChild2 : mChild1;
		final View ch2 = mFlipChildPos ? mChild1 : mChild2;
		final int paddingLeft = getPaddingLeft();
		final int paddingTop = getPaddingTop();
		callChildLayout(ch2, changed, left - paddingLeft, top - paddingTop, right - paddingLeft, bottom - paddingTop);
		if (mEnableSubWindow) {
			// child1の位置はchild2の左下か右上
			final int _left = ch2.getLeft();
			final int _top = ch2.getTop();
			final int _right = ch2.getRight();
			final int _bottom = ch2.getBottom();
			final int w = ch1.getMeasuredWidth(); // int)((right - left) * mSubWindowScale);
			final int h = ch1.getMeasuredHeight(); // int)((bottom - top) * mSubWindowScale);
			switch (mOrientation) {
			case VERTICAL:
				callChildLayout(ch1, changed, _right - w, _top, _right, _top + h);
				break;
//			case HORIZONTAL:
			default:
				callChildLayout(ch1, changed, _left, _bottom - h, _left + w, _bottom);
				break;
			}
		}
	}
 
private int findMotionHeader(float y) {
    if (mStickiedHeader != null && y <= mHeaderBottomPosition) {
        return MATCHED_STICKIED_HEADER;
    }

    int vi = 0;
    for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition();) {
        long id = getItemIdAtPosition(i);
        if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {
            View headerWrapper = getChildAt(vi);

            int bottom = headerWrapper.getBottom();
            int top = headerWrapper.getTop();
            if (y <= bottom && y >= top) {
                return vi;
            }
        }
        i += mNumMeasuredColumns;
        vi += mNumMeasuredColumns;
    }

    return NO_MATCHED_HEADER;
}
 
源代码4 项目: Bailan   文件: RecycleViewDivider.java
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getMeasuredWidth() - parent.getPaddingRight();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getBottom() + layoutParams.bottomMargin;
        final int bottom = top + mDividerHeight;
        if (mDivider != null) {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        if (mPaint != null) {
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
 
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, BaseSectionAdapter.ItemViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    View itemView = viewHolder.itemView;
    int itemHeight = itemView.getBottom() - itemView.getTop();
    background.setColor(color);
    background.setBounds((int) (itemView.getRight() + dX), itemView.getTop(), itemView.getRight(), itemView.getBottom());
    background.draw(c);
    int deleteIconTop = itemView.getTop() + (itemHeight - deleteIcon.getIntrinsicHeight()) / 2;
    int deleteIconMargin = (itemHeight - deleteIcon.getIntrinsicHeight()) / 2;
    int deleteIconLeft = itemView.getRight() - deleteIconMargin - deleteIcon.getIntrinsicWidth();
    int deleteIconRight = itemView.getRight() - deleteIconMargin;
    int deleteIconBottom = deleteIconTop + deleteIcon.getIntrinsicHeight();
    deleteIcon.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom);
    deleteIcon.draw(c);
    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
 
源代码6 项目: Leisure   文件: DividerItemDecoration.java
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        android.support.v7.widget.RecyclerView v = new android.support.v7.widget.RecyclerView(parent.getContext());
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码7 项目: Mupdf   文件: DividerItemDecoration.java
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin +
                Math.round(ViewCompat.getTranslationY(child));
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码8 项目: NIM_Android_UIKit   文件: ImageItemDecoration.java
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    super.onDrawOver(c, parent, state);

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        if (child.getWidth() == ScreenUtil.getDisplayWidth()) {
            continue;
        }

        final int left = child.getLeft();
        final int right = child.getRight();
        final int top = child.getTop();
        final int bottom = child.getBottom();

        c.drawRect(left, bottom - dividerSize, right, bottom, paint);
        c.drawRect(right - dividerSize, top, right, bottom, paint);
    }
}
 
源代码9 项目: UltimateAndroid   文件: DragSortListView.java
private int getTargetY() {
    final int first = getFirstVisiblePosition();
    final int otherAdjust = (mItemHeightCollapsed + getDividerHeight()) / 2;
    View v = getChildAt(mDropPos - first);
    int targetY = -1;
    if (v != null) {
        if (mDropPos == srcPos) {
            targetY = v.getTop();
        } else if (mDropPos < srcPos) {
            // expanded down
            targetY = v.getTop() - otherAdjust;
        } else {
            // expanded up
            targetY = v.getBottom() + otherAdjust - mFloatViewHeight;
        }
    } else {
        // drop position is not on screen?? no animation
        cancel();
    }

    return targetY;
}
 
源代码10 项目: ListItemFold   文件: FoldLayout.java
protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) v;
        int scrollX = v.getScrollX();
        int scrollY = v.getScrollY();
        for (int i = group.getChildCount() - 1; i >= 0; i--) {
            View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom()) {
                if (canScroll(child, true, dy, (x + scrollX) - child.getLeft(), (y + scrollY) - child.getTop())) {
                    return true;
                }
            }
        }
    }
    return checkV && ViewCompat.canScrollVertically(v, -dy);
}
 
源代码11 项目: material   文件: DatePicker.java
@Override
public void run() {
    mCurrentScrollState = mNewState;
    // Fix the position after a scroll or a fling ends
    if (mNewState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != AbsListView.OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
        mPreviousScrollState = mNewState;

        int i = 0;
        View child = getChildAt(i);
        while(child != null && child.getBottom() <= 0)
            child = getChildAt(++i);
        if (child == null)
            return;

        int firstPosition = getFirstVisiblePosition();
        int lastPosition = getLastVisiblePosition();
        boolean scroll = firstPosition != 0 && lastPosition != getCount() - 1;
        final int top = child.getTop();
        final int bottom = child.getBottom();
        final int midpoint = getHeight() / 2;
        if (scroll && top < LIST_TOP_OFFSET) {
            if (bottom > midpoint)
                smoothScrollBy(top, SCROLL_DURATION);
            else
                smoothScrollBy(bottom, SCROLL_DURATION);
        }
    }
    else
        mPreviousScrollState = mNewState;
}
 
源代码12 项目: DidiLayout   文件: DidiViewDragHelper.java
/**
 * Determine if the supplied view is under the given point in the
 * parent view's coordinate system.
 *
 * @param view Child view of the parent to hit test
 * @param x    X position to test in the parent's coordinate system
 * @param y    Y position to test in the parent's coordinate system
 * @return true if the supplied view is under the given point, false otherwise
 */
public boolean isViewUnder(View view, int x, int y) {
    if (view == null) {
        return false;
    }
    return x >= view.getLeft() &&
            x < view.getRight() &&
            y >= view.getTop() &&
            y < view.getBottom();
}
 
源代码13 项目: ExpressHelper   文件: ViewDragHelper.java
/**
 * Find the topmost child under the given point within the parent view's
 * coordinate system. The child order is determined using
 * {@link me.imid.swipebacklayout.lib.ViewDragHelper.Callback#getOrderedChildIndex(int)}
 * .
 *
 * @param x X position to test in the parent's coordinate system
 * @param y Y position to test in the parent's coordinate system
 * @return The topmost child view under (x, y) or null if none found.
 */
public View findTopChildUnder(int x, int y) {
    final int childCount = mParentView.getChildCount();
    for (int i = childCount - 1; i >= 0; i--) {
        final View child = mParentView.getChildAt(mCallback.getOrderedChildIndex(i));
        if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop()
                && y < child.getBottom()) {
            return child;
        }
    }
    return null;
}
 
private boolean isLastItemVisible() {
	final Adapter adapter = mRefreshableView.getAdapter();

	if (null == adapter || adapter.isEmpty()) {
		if (DEBUG) {
			Log.d(LOG_TAG, "isLastItemVisible. Empty View.");
		}
		return true;
	} else {
		final int lastItemPosition = mRefreshableView.getCount() - 1;
		final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();

		if (DEBUG) {
			Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: "
					+ lastVisiblePosition);
		}

		/**
		 * This check should really just be: lastVisiblePosition ==
		 * lastItemPosition, but PtRListView internally uses a FooterView
		 * which messes the positions up. For me we'll just subtract one to
		 * account for it and rely on the inner condition which checks
		 * getBottom().
		 */
		if (lastVisiblePosition >= lastItemPosition - 1) {
			final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition();
			final View lastVisibleChild = mRefreshableView.getChildAt(childIndex);
			if (lastVisibleChild != null) {
				return lastVisibleChild.getBottom() <= mRefreshableView.getBottom();
			}
		}
	}

	return false;
}
 
源代码15 项目: photo-editor-android   文件: ViewDragHelper.java
/**
 * Determine if the supplied view is under the given point in the
 * parent view's coordinate system.
 *
 * @param view Child view of the parent to hit test
 * @param x X position to test in the parent's coordinate system
 * @param y Y position to test in the parent's coordinate system
 * @return true if the supplied view is under the given point, false otherwise
 */
public boolean isViewUnder(View view, int x, int y) {
    if (view == null) {
        return false;
    }
    return x >= view.getLeft() &&
            x < view.getRight() &&
            y >= view.getTop() &&
            y < view.getBottom();
}
 
源代码16 项目: Android-WYSIWYG-Editor   文件: EditorCore.java
private boolean isViewInBounds(View view, float x, float y){

        Rect outRect = new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());

        if(outRect.contains((int)x, (int)y))
        {
            return true;
        }
        return false;
    }
 
源代码17 项目: material-components-android   文件: AppBarLayout.java
@Nullable
private static View getAppBarChildOnOffset(
    @NonNull final AppBarLayout layout, final int offset) {
  final int absOffset = Math.abs(offset);
  for (int i = 0, z = layout.getChildCount(); i < z; i++) {
    final View child = layout.getChildAt(i);
    if (absOffset >= child.getTop() && absOffset <= child.getBottom()) {
      return child;
    }
  }
  return null;
}
 
源代码18 项目: HightCopyWX   文件: ChatActivity.java
private boolean isKeyboardShown(View rootView) {
    final int softKeyboardHeight = 100;
    Rect r = new Rect();
    // 获取根布局的可视区域r
    rootView.getWindowVisibleDisplayFrame(r);
    DisplayMetrics dm = rootView.getResources().getDisplayMetrics();
    // 本来的实际底部距离 - 可视的底部距离
    int heightDiff = rootView.getBottom() - r.bottom;
    return heightDiff > softKeyboardHeight * dm.density;
}
 
源代码19 项目: UltimateAndroid   文件: DividerItemDecoration.java
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码20 项目: Trebuchet   文件: Workspace.java
@Override
protected void getEdgeVerticalPostion(int[] pos) {
    View child = getChildAt(getPageCount() - 1);
    pos[0] = child.getTop();
    pos[1] = child.getBottom();
}
 
 方法所在类
 同类方法