Java Code Examples for android.view.View#getBottom()
The following examples show how to use
android.view.View#getBottom() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TwoPanelViewGroup.java From libcommon with Apache License 2.0 | 6 votes |
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; } } }
Example 2
Source File: FoldLayout.java From ListItemFold with MIT License | 6 votes |
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); }
Example 3
Source File: DragSortListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: ImageItemDecoration.java From NIM_Android_UIKit with MIT License | 6 votes |
@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); } }
Example 5
Source File: DividerItemDecoration.java From Mupdf with Apache License 2.0 | 6 votes |
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); } }
Example 6
Source File: DividerItemDecoration.java From Leisure with GNU Lesser General Public License v3.0 | 6 votes |
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); } }
Example 7
Source File: DemoSwipeCallback.java From sectioned-recycler-view with MIT License | 6 votes |
@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); }
Example 8
Source File: RecycleViewDivider.java From Bailan with Apache License 2.0 | 6 votes |
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); } } }
Example 9
Source File: StickyGridHeadersGridView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
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; }
Example 10
Source File: LMRecyclerView.java From WanAndroid with Apache License 2.0 | 6 votes |
/** * 滑动监听 * @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(); } } } }
Example 11
Source File: DidiViewDragHelper.java From DidiLayout with Apache License 2.0 | 5 votes |
/** * 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(); }
Example 12
Source File: DatePicker.java From material with Apache License 2.0 | 5 votes |
@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; }
Example 13
Source File: ViewDragHelper.java From ExpressHelper with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example 14
Source File: PullToRefreshAdapterViewBase.java From PullToRefreshLibrary with Apache License 2.0 | 5 votes |
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; }
Example 15
Source File: ViewDragHelper.java From photo-editor-android with MIT License | 5 votes |
/** * 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(); }
Example 16
Source File: EditorCore.java From Android-WYSIWYG-Editor with Apache License 2.0 | 5 votes |
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; }
Example 17
Source File: AppBarLayout.java From material-components-android with Apache License 2.0 | 5 votes |
@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; }
Example 18
Source File: ChatActivity.java From HightCopyWX with Apache License 2.0 | 5 votes |
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; }
Example 19
Source File: DividerItemDecoration.java From UltimateAndroid with Apache License 2.0 | 5 votes |
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); } }
Example 20
Source File: Workspace.java From Trebuchet with GNU General Public License v3.0 | 4 votes |
@Override protected void getEdgeVerticalPostion(int[] pos) { View child = getChildAt(getPageCount() - 1); pos[0] = child.getTop(); pos[1] = child.getBottom(); }