Java Code Examples for android.view.View.getBottom()

The following are Jave code examples for showing how to use getBottom() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: letv   File: ViewPager.java   Source Code and License Vote up 7 votes
protected boolean canScroll(View v, boolean checkV, int dx, 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, dx, (x + scrollX) - child.getLeft(), (y + scrollY) - child.getTop())) {
                    return true;
                }
            }
        }
    }
    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}
 
Example 2
Project: AssistantBySDK   File: DayPickerView.java   Source Code and License Vote up 7 votes
/**
 * Gets the position of the view that is most prominently displayed within the list view.
 */
public int getMostVisiblePosition() {
    final int firstPosition = getFirstVisiblePosition();
    final int height = getHeight();

    int maxDisplayedHeight = 0;
    int mostVisibleIndex = 0;
    int i=0;
    int bottom = 0;
    while (bottom < height) {
        View child = getChildAt(i);
        if (child == null) {
            break;
        }
        bottom = child.getBottom();
        int displayedHeight = Math.min(bottom, height) - Math.max(0, child.getTop());
        if (displayedHeight > maxDisplayedHeight) {
            mostVisibleIndex = i;
            maxDisplayedHeight = displayedHeight;
        }
        i++;
    }
    return firstPosition + mostVisibleIndex;
}
 
Example 3
Project: Android-HTTPS-based-on-MVVM   File: DividerItemDecoration.java   Source Code and License Vote up 7 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 4
Project: SunmiUI   File: ImageSharedTransitionActivity.java   Source Code and License Vote up 7 votes
private void performCircularReveal(View show) {
    show.setBackgroundColor(0xffff0000);
    ViewCompat.setTranslationY(show, 0);
    ViewCompat.setTranslationX(show, 0);
    show.getLayoutParams().height = 500;
    show.getLayoutParams().width = 1920;
    show.requestLayout();
    int centerX = (show.getLeft() + show.getRight()) / 2;
    int centerY = (show.getTop() + show.getBottom()) / 2;
    float finalRadius = (float) Math.hypot((double) centerX, (double) centerY);
    Animator mCircularReveal = ViewAnimationUtils.createCircularReveal(
            show, centerX, centerY, 0, finalRadius);
    mCircularReveal.setInterpolator(new AccelerateDecelerateInterpolator());
    mCircularReveal.setDuration(500);
    mCircularReveal.start();
}
 
Example 5
Project: decoy   File: DividerItemDecoration.java   Source Code and License Vote up 7 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 6
Project: Quran   File: SlidingUpPanelLayout.java   Source Code and License Vote up 7 votes
/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx Delta scrolled in pixels
 * @param x X coordinate of the active touch point
 * @param y Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
  if (v instanceof ViewGroup) {
    final ViewGroup group = (ViewGroup) v;
    final int scrollX = v.getScrollX();
    final int scrollY = v.getScrollY();
    final int count = group.getChildCount();
    // Count backwards - let topmost views consume scroll distance first.
    for (int i = count - 1; i >= 0; i--) {
      final View child = group.getChildAt(i);
      if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
          y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
          canScroll(child, true, dx, x + scrollX - child.getLeft(),
              y + scrollY - child.getTop())) {
        return true;
      }
    }
  }
  return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}
 
Example 7
Project: GitHub   File: DividerItemDecoration.java   Source Code and License Vote up 7 votes
private void draw(Canvas c, RecyclerView parent) {
	int left = parent.getPaddingLeft();
	int right = parent.getWidth() - parent.getPaddingRight();

	int childCount = parent.getChildCount();
	for (int i = 0; i < childCount; i++) {
		View child = parent.getChildAt(i);

		RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

		int top = child.getBottom() + params.bottomMargin +
				Math.round(ViewCompat.getTranslationY(child));
		int bottom = top + mDivider.getIntrinsicHeight() + 1;

		mDivider.setBounds(left, top, right, bottom);
		mDivider.draw(c);
	}
}
 
Example 8
Project: MyRepository   File: DividerGridItemDecoration.java   Source Code and License Vote up 7 votes
public void drawVertical(Canvas c, RecyclerView parent) {
    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.getTop() - params.topMargin;
        final int bottom = child.getBottom() + params.bottomMargin;
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicWidth();

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 9
Project: underlx   File: SimpleDividerItemDecoration.java   Source Code and License Vote up 7 votes
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();

    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);

        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        int top = child.getBottom() + params.bottomMargin;
        int bottom = top + mDivider.getIntrinsicHeight();

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 10
Project: OpenHub   File: DividerItemDecoration.java   Source Code and License Vote up 7 votes
private void drawVertical(@NonNull Canvas c, @NonNull 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);
        RecyclerView v = new 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 11
Project: NightSkyGuide   File: ItemDivider.java   Source Code and License Vote up 7 votes
@Override
public void onDrawOver(Canvas c, RecyclerView parent,
    RecyclerView.State state) {
    super.onDrawOver(c, parent, state);

    // calculate left/right x-coordinates for all dividers
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();

    // for every item but the last, draw a line below it
    for (int i = 0; i < parent.getChildCount() - 1; ++i) {
        View item = parent.getChildAt(i);  // get ith list item

        // calculate top/bottom y-coordinates for current divider
        int top = item.getBottom() + ((RecyclerView.LayoutParams)
            item.getLayoutParams()).bottomMargin;
        int bottom = top + divider.getIntrinsicHeight();

        // draw the divider with the calculated bounds
        divider.setBounds(left, top, right, bottom);
        divider.draw(c);
    }
}
 
Example 12
Project: RX_Demo   File: ResideLayout.java   Source Code and License Vote up 7 votes
/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx     Delta scrolled in pixels
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
                    y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
                    canScroll(child, true, dx, x + scrollX - child.getLeft(),
                            y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && ViewCompat.canScrollHorizontally(v, (-dx));
}
 
Example 13
Project: buildAPKsSamples   File: ExpandingListView.java   Source Code and License Vote up 6 votes
/**
 * This method takes some view and the values by which its top and bottom bounds
 * should be changed by. Given these params, an animation which will animate
 * these bound changes is created and returned.
 */
private Animator getAnimation(final View view, float translateTop, float translateBottom) {

    int top = view.getTop();
    int bottom = view.getBottom();

    int endTop = (int)(top + translateTop);
    int endBottom = (int)(bottom + translateBottom);

    PropertyValuesHolder translationTop = PropertyValuesHolder.ofInt("top", top, endTop);
    PropertyValuesHolder translationBottom = PropertyValuesHolder.ofInt("bottom", bottom,
            endBottom);

    return ObjectAnimator.ofPropertyValuesHolder(view, translationTop, translationBottom);
}
 
Example 14
Project: GitHub   File: CommonNavigator.java   Source Code and License Vote up 6 votes
/**
 * 获取title的位置信息,为打造不同的指示器、各种效果提供可能
 */
private void preparePositionData() {
    mPositionDataList.clear();
    for (int i = 0, j = mNavigatorHelper.getTotalCount(); i < j; i++) {
        PositionData data = new PositionData();
        View v = mTitleContainer.getChildAt(i);
        if (v != null) {
            data.mLeft = v.getLeft();
            data.mTop = v.getTop();
            data.mRight = v.getRight();
            data.mBottom = v.getBottom();
            if (v instanceof IMeasurablePagerTitleView) {
                IMeasurablePagerTitleView view = (IMeasurablePagerTitleView) v;
                data.mContentLeft = view.getContentLeft();
                data.mContentTop = view.getContentTop();
                data.mContentRight = view.getContentRight();
                data.mContentBottom = view.getContentBottom();
            } else {
                data.mContentLeft = data.mLeft;
                data.mContentTop = data.mTop;
                data.mContentRight = data.mRight;
                data.mContentBottom = data.mBottom;
            }
        }
        mPositionDataList.add(data);
    }
}
 
Example 15
Project: boohee_v5.6   File: ViewDragHelper.java   Source Code and License Vote up 6 votes
public View findTopChildUnder(int x, int y) {
    for (int i = this.mParentView.getChildCount() - 1; i >= 0; i--) {
        View child = this.mParentView.getChildAt(this.mCallback.getOrderedChildIndex(i));
        if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) {
            return child;
        }
    }
    return null;
}
 
Example 16
Project: RLibrary   File: StickLayoutManager.java   Source Code and License Vote up 6 votes
private int getStickTop() {
    View view = findViewByPosition(stickPosition - 1);
    if (view == null) {
        view = findViewByPosition(stickPosition + 1);
        if (view == null) {
            return 0;
        } else {
            return view.getTop() - stickViewHeight;
        }
    } else {
        return view.getBottom();
    }
}
 
Example 17
Project: FlickLauncher   File: Workspace.java   Source Code and License Vote up 6 votes
boolean isPointInSelfOverHotseat(int x, int y) {
    mTempXY[0] = x;
    mTempXY[1] = y;
    mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
    View hotseat = mLauncher.getHotseat();
    return mTempXY[0] >= hotseat.getLeft() &&
            mTempXY[0] <= hotseat.getRight() &&
            mTempXY[1] >= hotseat.getTop() &&
            mTempXY[1] <= hotseat.getBottom();
}
 
Example 18
Project: android-project-gallery   File: DividerGridItemDecoration.java   Source Code and License Vote up 6 votes
public void drawHorizontal(Canvas c, RecyclerView parent)
{
	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 left = child.getLeft() - params.leftMargin;
		final int right = child.getRight() + params.rightMargin + mDivider.getIntrinsicWidth();
		final int top = child.getBottom() + params.bottomMargin;
		final int bottom = top + mDivider.getIntrinsicHeight();
		mDivider.setBounds(left, top, right, bottom);
		mDivider.draw(c);
	}
}
 
Example 19
Project: ItemDecorations   File: LinearItemDecoration.java   Source Code and License Vote up 5 votes
@Override
void drawHorizontalOrientationDividers(Canvas c, RecyclerView parent,
                                       RecyclerView.LayoutManager layoutManager) {
    LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
    int childCount = parent.getChildCount();
    float left, top, right, bottom;
    for (int i = 0; i < childCount; i++) {
        View view = parent.getChildAt(i);
        RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) view.getLayoutParams();
        int position = lp.getViewAdapterPosition();
        if (position < 0 || !mProvider.isDividerNeedDraw(position))
            continue;
        float transitionX = ViewCompat.getTranslationX(view);
        float transitionY = ViewCompat.getTranslationY(view);
        top = view.getTop() - lp.topMargin + transitionY + mProvider.marginStart(position);
        bottom = view.getBottom() + lp.bottomMargin + transitionY - mProvider.marginEnd(position);
        IDivider divider = mProvider.createDivider(position);
        if (manager.getReverseLayout()) {
            if (divider.getType() == IDivider.TYPE_DRAWABLE) {
                right = view.getLeft() - lp.leftMargin + transitionX;
                left = right - divider.getDividerSize();
            } else {
                left = view.getLeft() - lp.leftMargin - divider.getDividerSize() / 2f + transitionY;
                right = left;
            }
            if (mDrawInsideEachOfItem) {
                left += divider.getDividerSize();
                right += divider.getDividerSize();
            }
        } else {
            if (divider.getType() == IDivider.TYPE_DRAWABLE) {
                left = view.getRight() + lp.rightMargin + transitionX;
                right = left + divider.getDividerSize();
            } else {
                left = view.getRight() + lp.rightMargin + divider.getDividerSize() / 2f + transitionX;
                right = left;
            }
            if (mDrawInsideEachOfItem) {
                left -= divider.getDividerSize();
                right -= divider.getDividerSize();
            }
        }
        divider.draw(c, left, top, right, bottom);
    }
}
 
Example 20
Project: gridlayout   File: FGridLayout.java   Source Code and License Vote up 5 votes
@Override
protected void onDraw(Canvas canvas)
{
    super.onDraw(canvas);
    canvas.save();

    final boolean drawHor = mHorizontalDivider != null && mArrRowHeight.size() > 1;
    final boolean drawVer = mVerticalDivider != null && mArrColumnWidth.size() > 1;

    if (drawHor || drawVer)
    {
        final int lastRow = mArrRowHeight.size() - 1;
        final int lastCol = mArrColumnWidth.size() - 1;

        int row = 0;
        int col = 0;
        View child = null;

        int left = 0;
        int top = 0;
        int right = 0;
        int bottom = 0;

        int count = getChildCount();
        for (int i = 0; i < count; i++)
        {
            row = getRowIndex(i);
            col = getColumnIndex(i);
            child = getChildAt(i);

            if (drawHor && row < lastRow)
            {
                left = child.getLeft();
                top = child.getBottom();
                right = child.getRight();
                bottom = top + mHorizontalDivider.getIntrinsicHeight();

                if (mPreferHorizontalDivider && col < lastCol)
                {
                    right += getVerticalSpacing();
                }

                mHorizontalDivider.setBounds(left, top, right, bottom);
                mHorizontalDivider.draw(canvas);
            }

            if (drawVer && col < lastCol)
            {
                left = child.getRight();
                top = child.getTop();
                right = left + mVerticalDivider.getIntrinsicWidth();
                bottom = child.getBottom();

                if (!mPreferHorizontalDivider && row < lastRow)
                {
                    bottom += getHorizontalSpacing();
                }

                mVerticalDivider.setBounds(left, top, right, bottom);
                mVerticalDivider.draw(canvas);
            }
        }
    }

    canvas.restore();
}