List of usage examples for android.view View getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:com.aidy.launcher3.support.views.bottomdrawer.BottomDrawerLayout.java
/** * Open the specified drawer view by animating it into view. * //from ww w. j av a 2 s . c o m * @param drawerView * Drawer view to open */ public void openDrawer(View drawerView) { Log.i(TAG, "openDrawer() --view"); if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); } Log.i(TAG, "openDrawer() -- mFirstLayout = " + mFirstLayout); if (mFirstLayout) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); lp.onScreen = 1.f; lp.knownOpen = true; } else { if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.BOTTOM)) { mBottomDragger.smoothSlideViewTo(drawerView, drawerView.getLeft(), getHeight() - drawerView.getHeight()); } } invalidate(); }
From source file:com.android.hcframe.DraggableGridViewPager.java
private void animateGap(int target) { for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); if (i == mLastDragged) { continue; }//www .j a v a 2 s . c o m int newPos = i; if (mLastDragged < target && i >= mLastDragged + 1 && i <= target) { newPos--; } else if (target < mLastDragged && i >= target && i < mLastDragged) { newPos++; } int oldPos = i; if (newPositions.get(i) != -1) { oldPos = newPositions.get(i); } if (oldPos == newPos) { continue; } // animate HcLog.D("animateGap from=" + oldPos + ", to=" + newPos); final Rect oldRect = getRectByPosition(oldPos); final Rect newRect = getRectByPosition(newPos); oldRect.offset(-v.getLeft(), -v.getTop()); newRect.offset(-v.getLeft(), -v.getTop()); TranslateAnimation translate = new TranslateAnimation(oldRect.left, newRect.left, oldRect.top, newRect.top); translate.setDuration(ANIMATION_DURATION); translate.setFillEnabled(true); translate.setFillAfter(true); v.clearAnimation(); v.startAnimation(translate); newPositions.set(i, newPos); } }
From source file:bw.com.yunifangstore.view.LazyViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null;// ww w. j a v a 2 s.c om boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) { currentFocused = null;//from www .j a v a2s . c om } boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:android.widget.Gallery.java
/** * Detaches children that are off the screen (i.e.: Gallery bounds). * // w w w.j av a2 s . co m * @param toLeft Whether to detach children to the left of the Gallery, or * to the right. */ private void detachOffScreenChildren(boolean toLeft) { int numChildren = getChildCount(); int firstPosition = mFirstPosition; int start = 0; int count = 0; if (toLeft) { final int galleryLeft = mPaddingLeft; for (int i = 0; i < numChildren; i++) { int n = mIsRtl ? (numChildren - 1 - i) : i; final View child = getChildAt(n); if (child.getRight() >= galleryLeft) { break; } else { start = n; count++; mRecycler.put(firstPosition + n, child); } } if (!mIsRtl) { start = 0; } } else { final int galleryRight = getWidth() - mPaddingRight; for (int i = numChildren - 1; i >= 0; i--) { int n = mIsRtl ? numChildren - 1 - i : i; final View child = getChildAt(n); if (child.getLeft() <= galleryRight) { break; } else { start = n; count++; mRecycler.put(firstPosition + n, child); } } if (mIsRtl) { start = 0; } } detachViewsFromParent(start, count); if (toLeft != mIsRtl) { mFirstPosition += count; } }
From source file:com.common.view.slidingfinish.CustomSlidingPaneLayout.java
void updateObscuredViewsVisibility(View panel) { final boolean isLayoutRtl = isLayoutRtlSupport(); final int startBound = isLayoutRtl ? (getWidth() - getPaddingRight()) : getPaddingLeft(); final int endBound = isLayoutRtl ? getPaddingLeft() : (getWidth() - getPaddingRight()); final int topBound = getPaddingTop(); final int bottomBound = getHeight() - getPaddingBottom(); final int left; final int right; final int top; final int bottom; if (panel != null && viewIsOpaque(panel)) { left = panel.getLeft(); right = panel.getRight();/*from www . ja va 2s . c o m*/ 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((isLayoutRtl ? endBound : startBound), child.getLeft()); final int clampedChildTop = Math.max(topBound, child.getTop()); final int clampedChildRight = Math.min((isLayoutRtl ? startBound : endBound), child.getRight()); final int clampedChildBottom = Math.min(bottomBound, 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:aksha.upcomingdemo.HorizontalListView.java
/** Draws the dividers that go in between the horizontal list view items */ private void drawDividers(Canvas canvas) { final int count = getChildCount(); // Only modify the left and right in the loop, we set the top and bottom here since they are always the same final Rect bounds = mRect; mRect.top = getPaddingTop();/*from w w w . j a va2 s . c o m*/ mRect.bottom = mRect.top + getRenderHeight(); // Draw the list dividers for (int i = 0; i < count; i++) { // Don't draw a divider to the right of the last item in the adapter if (!(i == count - 1 && isLastItemInAdapter(mRightViewAdapterIndex))) { View child = getChildAt(i); bounds.left = child.getRight(); bounds.right = child.getRight() + mDividerWidth; // Clip at the left edge of the screen if (bounds.left < getPaddingLeft()) { bounds.left = getPaddingLeft(); } // Clip at the right edge of the screen if (bounds.right > getWidth() - getPaddingRight()) { bounds.right = getWidth() - getPaddingRight(); } // Draw a divider to the right of the child drawDivider(canvas, bounds); // If the first view, determine if a divider should be shown to the left of it. // A divider should be shown if the left side of this view does not fill to the left edge of the screen. if (i == 0 && child.getLeft() > getPaddingLeft()) { bounds.left = getPaddingLeft(); bounds.right = child.getLeft(); drawDivider(canvas, bounds); } } } }
From source file:beichen.douban.ui.view.LazyViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * //from www.ja v a2 s . com * @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); }
From source file:android.support.v7.widget.LinearLayoutCompat.java
void drawDividersHorizontal(Canvas canvas) { final int count = getVirtualChildCount(); final boolean isLayoutRtl = ViewUtils.isLayoutRtl(this); for (int i = 0; i < count; i++) { final View child = getVirtualChildAt(i); if (child != null && child.getVisibility() != GONE) { if (hasDividerBeforeChildAt(i)) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int position; if (isLayoutRtl) { position = child.getRight() + lp.rightMargin; } else { position = child.getLeft() - lp.leftMargin - mDividerWidth; }// ww w.j a va2 s .c om drawVerticalDivider(canvas, position); } } } if (hasDividerBeforeChildAt(count)) { final View child = getVirtualChildAt(count - 1); int position; if (child == null) { if (isLayoutRtl) { position = getPaddingLeft(); } else { position = getWidth() - getPaddingRight() - mDividerWidth; } } else { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (isLayoutRtl) { position = child.getLeft() - lp.leftMargin - mDividerWidth; } else { position = child.getRight() + lp.rightMargin; } } drawVerticalDivider(canvas, position); } }
From source file:cn.zmdx.kaka.locker.widget.SlidingPaneLayout.java
void updateObscuredViewsVisibility(View panel) { final boolean isLayoutRtl = isLayoutRtlSupport(); final int startBound = isLayoutRtl ? (getWidth() - getPaddingRight()) : getPaddingLeft(); final int endBound = isLayoutRtl ? getPaddingLeft() : (getWidth() - getPaddingRight()); final int topBound = getPaddingTop(); final int bottomBound = getHeight() - getPaddingBottom(); final int left; final int right; final int top; final int bottom; if (panel != null && viewIsOpaque(panel)) { left = panel.getLeft(); right = panel.getRight();/*ww w . j a va 2 s. c o m*/ 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((isLayoutRtl ? endBound : startBound), child.getLeft()); final int clampedChildTop = Math.max(topBound, child.getTop()); final int clampedChildRight = Math.min((isLayoutRtl ? startBound : endBound), child.getRight()); final int clampedChildBottom = Math.min(bottomBound, child.getBottom()); final int vis; if (clampedChildLeft >= left && clampedChildTop >= top && clampedChildRight <= right && clampedChildBottom <= bottom) { vis = INVISIBLE; } else { vis = VISIBLE; } child.setVisibility(vis); } }