List of usage examples for android.view View getBottom
@ViewDebug.CapturedViewProperty public final int getBottom()
From source file:android.improving.utils.views.swipeback.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * //from w w w .j a v a 2 s.c o m * @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 along the X axis * @param dy * Delta scrolled in pixels along the Y axis * @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 dy, 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, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.hippo.widget.recyclerview.EasyRecyclerView.java
private void positionSelector(int position, View sel, boolean manageHotspot, float x, float y) { final boolean positionChanged = position != mSelectorPosition; if (position != INVALID_POSITION) { mSelectorPosition = position;//from w w w.ja va 2s .c om } final Rect selectorRect = mSelectorRect; selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom()); // Adjust for selection padding. selectorRect.left -= mSelectionLeftPadding; selectorRect.top -= mSelectionTopPadding; selectorRect.right += mSelectionRightPadding; selectorRect.bottom += mSelectionBottomPadding; // Update the selector drawable. final Drawable selector = mSelector; if (selector != null) { if (positionChanged) { // Wipe out the current selector state so that we can start // over in the new position with a fresh state. selector.setVisible(false, false); selector.setState(StateSet.NOTHING); } selector.setBounds(selectorRect); if (positionChanged) { if (getVisibility() == VISIBLE) { selector.setVisible(true, false); } updateSelectorState(); } if (manageHotspot) { DrawableUtils.setHotspot(selector, x, y); } } }
From source file:com.yangpeiyong.widget.SlidingPaneLayout.java
/** * 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/*www . j a va 2 s . c o m*/ * @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) || ((v instanceof ViewPager) && canViewPagerScrollHorizontally((ViewPager) v, -dx))); // return checkV && ViewCompat.canScrollHorizontally(v, (isLayoutRtlSupport() ? dx : -dx)); }
From source file:com.xiaosu.lib.base.widget.drawerLayout.DrawerLayout.java
View findTopChildUnder(View view, int x, int y) { if (view instanceof ViewGroup) { ViewGroup parent = (ViewGroup) view; final int childCount = parent.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { final View child = parent.getChildAt(i); if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) { return child; }//from www . j a va 2 s. c om } } return null; }
From source file:com.xiaosu.lib.base.widget.drawerLayout.DrawerLayout.java
private boolean anyChildWantMotionEvent(MotionEvent ev, ViewGroup group) { MotionEvent event = MotionEvent.obtain(ev); event.offsetLocation(-group.getLeft(), -group.getTop()); //view//from w w w. j ava2 s. c o m int childCount = group.getChildCount(); final float x = event.getX(); final float y = event.getY(); for (int i = 0; i < childCount; i++) { View child = group.getChildAt(i); if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) { if (child instanceof ViewGroup) { MotionEvent chileEvent = MotionEvent.obtain(event); chileEvent.offsetLocation(-child.getLeft(), -child.getTop()); if (anyChildWantMotionEvent(chileEvent, (ViewGroup) child)) { chileEvent.recycle(); return true; } } else if (child.onTouchEvent(event)) { return true; } } } event.recycle(); return false; }
From source file:com.youle.gamebox.ui.view.SlidingPaneLayout.java
/** * 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//w ww. j a v a 2 s. c o m * @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(!child.isAttachedToWindow()) continue; 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) || ((v instanceof ViewPager) && canViewPagerScrollHorizontally((ViewPager) v, -dx))); }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { View v = getCurrentFocus(); if (v instanceof EditText) { int scrcoords[] = new int[2]; v.getLocationOnScreen(scrcoords); float x = event.getRawX() + v.getLeft() - scrcoords[0]; float y = event.getRawY() + v.getTop() - scrcoords[1]; if (x < v.getLeft() || x >= v.getRight() || y < v.getTop() || y > v.getBottom()) { // Tapped outside the editText UIUtils.hideKeyboard(this, v); }/* w w w . ja v a2 s.c om*/ } } return super.dispatchTouchEvent(event); }
From source file:com.waz.zclient.pages.main.conversationpager.SlidingPaneLayout.java
@Override public void draw(Canvas c) { super.draw(c); final boolean isLayoutRtl = isLayoutRtlSupport(); Drawable shadowDrawable;//from www . j a v a2 s.c o m if (isLayoutRtl) { shadowDrawable = shadowDrawableRight; } else { shadowDrawable = shadowDrawableLeft; } final View shadowView = getChildCount() > 1 ? getChildAt(1) : null; if (shadowView == null || shadowDrawable == null) { // No need to draw a shadow if we don't have one. return; } final int top = shadowView.getTop(); final int bottom = shadowView.getBottom(); final int shadowWidth = shadowDrawable.getIntrinsicWidth(); final int left; final int right; if (isLayoutRtlSupport()) { left = shadowView.getRight(); right = left + shadowWidth; } else { right = shadowView.getLeft(); left = right - shadowWidth; } shadowDrawable.setBounds(left, top, right, bottom); shadowDrawable.draw(c); }
From source file:com.android.dialer.widget.OverlappingPaneLayout.java
void updateObscuredViewsVisibility(View panel) { final int startBound = getPaddingTop(); final int endBound = getHeight() - getPaddingBottom(); final int leftBound = getPaddingLeft(); final int rightBound = getWidth() - getPaddingRight(); final int left; final int right; final int top; final int bottom; if (panel != null && viewIsOpaque(panel)) { left = panel.getLeft();//from ww w . jav a 2 s .com right = panel.getRight(); top = panel.getTop(); bottom = panel.getBottom(); } else { left = right = top = bottom = 0; } for (int i = 0, childCount = getChildCount(); i < childCount; i++) { final View child = getChildAt(i); if (child == panel) { // There are still more children above the panel but they won't be affected. break; } final int clampedChildLeft = Math.max(leftBound, child.getLeft()); final int clampedChildRight = Math.min(rightBound, child.getRight()); final int clampedChildTop = Math.max(startBound, child.getTop()); final int clampedChildBottom = Math.min(endBound, child.getBottom()); final int vis; if (clampedChildLeft >= left && clampedChildTop >= top && clampedChildRight <= right && clampedChildBottom <= bottom) { vis = INVISIBLE; } else { vis = VISIBLE; } child.setVisibility(vis); } }
From source file:cn.zmdx.kaka.locker.widget.SlidingPaneLayout.java
/** * Tests scrollability within child views of v given a delta of dx. * /*w ww . ja v a 2 s.c om*/ * @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, (isLayoutRtlSupport() ? dx : -dx)); }