List of usage examples for android.view View getBottom
@ViewDebug.CapturedViewProperty public final int getBottom()
From source file:com.jzh.stuapp.view.MyViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * /* ww 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 * @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(); 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); }
From source file:cn.emagsoftware.ui.BugFixedSlidingPaneLayout.java
@Override public void draw(Canvas c) { super.draw(c); final View shadowView = getChildCount() > 1 ? getChildAt(1) : null; if (shadowView == null || mShadowDrawable == null) { // No need to draw a shadow if we don't have one. return;//from w w w . j a va2s. c om } final int shadowWidth = mShadowDrawable.getIntrinsicWidth(); final int right = shadowView.getLeft(); final int top = shadowView.getTop(); final int bottom = shadowView.getBottom(); final int left = right - shadowWidth; mShadowDrawable.setBounds(left, top, right, bottom); mShadowDrawable.draw(c); }
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final int width = getWidth(); final boolean drawingContent = isContentView(child); int clipTop = 0, clipBottom = getHeight(); final int restoreCount = canvas.save(); if (drawingContent) { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View v = getChildAt(i); if (v == child || v.getVisibility() != VISIBLE || !hasOpaqueBackground(v) || !isDrawerView(v) || v.getWidth() < width) { continue; }/*ww w .ja v a2 s.c o m*/ if (checkDrawerViewGravity(v, Gravity.TOP)) { final int vbottom = v.getBottom(); if (vbottom > clipTop) clipTop = vbottom; } else { final int vtop = v.getTop(); if (vtop < clipBottom) clipBottom = vtop; } } canvas.clipRect(0, clipTop, getWidth(), clipBottom); } final boolean result = super.drawChild(canvas, child, drawingTime); canvas.restoreToCount(restoreCount); if (mScrimOpacity > 0 && drawingContent) { final int baseAlpha = (mScrimColor & 0xff000000) >>> 24; final int imag = (int) (baseAlpha * mScrimOpacity); final int color = imag << 24 | (mScrimColor & 0xffffff); mScrimPaint.setColor(color); canvas.drawRect(0, clipTop, getWidth(), clipBottom, mScrimPaint); } else if (mShadowTop != null && checkDrawerViewGravity(child, Gravity.TOP)) { final int shadowHeight = mShadowTop.getIntrinsicHeight(); final int childBottom = child.getBottom(); final int drawerPeekDistance = mTopDragger.getEdgeSize(); final float alpha = Math.max(0, Math.min((float) childBottom / drawerPeekDistance, 1.f)); mShadowTop.setBounds(child.getLeft(), childBottom, child.getRight(), childBottom + shadowHeight); mShadowTop.setAlpha((int) (0xff * alpha)); mShadowTop.draw(canvas); } else if (mShadowBottom != null && checkDrawerViewGravity(child, Gravity.BOTTOM)) { final int shadowHeight = mShadowBottom.getIntrinsicHeight(); final int childTop = child.getTop(); final int showing = getHeight() - childTop; final int drawerPeekDistance = mBottomDragger.getEdgeSize(); final float alpha = Math.max(0, Math.min((float) showing / drawerPeekDistance, 1.f)); mShadowTop.setBounds(child.getLeft(), childTop - shadowHeight, child.getRight(), childTop); mShadowBottom.setAlpha((int) (0xff * alpha)); mShadowBottom.draw(canvas); } return result; }
From source file:com.androzic.vnspeech.MapFragment.java
private void updateMapViewArea() { final ViewTreeObserver vto = map.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") public void onGlobalLayout() { View root = getView(); Rect area = new Rect(); map.getLocalVisibleRect(area); View v = root.findViewById(R.id.topbar); if (v != null) area.top = v.getBottom(); v = root.findViewById(R.id.bottombar); if (v != null) area.bottom = v.getTop(); if (mapLicense.isShown()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && mapLicense.getRotation() != 0f) area.left = mapLicense.getHeight(); // rotated view does not correctly report it's position else area.bottom = mapLicense.getTop(); }//from ww w . j a v a 2s.c om v = root.findViewById(R.id.rightbar); if (v != null) area.right = v.getLeft(); if (mapButtons.isShown()) { // Landscape mode if (v != null) area.bottom = mapButtons.getTop(); else area.right = mapButtons.getLeft(); } if (!area.isEmpty()) map.updateViewArea(area); ViewTreeObserver ob; if (vto.isAlive()) ob = vto; else ob = map.getViewTreeObserver(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { ob.removeGlobalOnLayoutListener(this); } else { ob.removeOnGlobalLayoutListener(this); } } }); }
From source file:com.comcast.freeflow.core.FreeFlowContainer.java
/** * Returns the actual frame for a view as its on stage. The FreeFlowItem's * frame object always represents the position it wants to be in but actual * frame may be different based on animation etc. * /*from w w w . j a va2 s. c o m*/ * @param freeflowItem * The freeflowItem to get the <code>Frame</code> for * @return The Frame for the freeflowItem or null if that view doesn't exist */ public Rect getActualFrame(final FreeFlowItem freeflowItem) { View v = freeflowItem.view; if (v == null) { return null; } Rect of = new Rect(); of.left = (int) (v.getLeft() + v.getTranslationX()); of.top = (int) (v.getTop() + v.getTranslationY()); of.right = (int) (v.getRight() + v.getTranslationX()); of.bottom = (int) (v.getBottom() + v.getTranslationY()); return of; }
From source file:com.icenler.lib.view.LazyViewPager.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//from w w w . 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--) { // 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:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.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)./*from ww w . j av a2 s.c o m*/ * @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:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java
/** * <p>Handles scrolling in response to a "home/end" shortcut press. This * method will scroll the view to the top or bottom and give the focus * to the topmost/bottommost component in the new visible area. If no * component is a good candidate for focus, this scrollview reclaims the * focus.</p>/* w w w . jav a 2s . c o m*/ * * @param direction the scroll direction: {@link android.view.View#FOCUS_UP} * to go the top of the view or * {@link android.view.View#FOCUS_DOWN} to go the bottom * @return true if the key event is consumed by this method, false otherwise */ public boolean fullScroll(int direction) { boolean down = direction == View.FOCUS_DOWN; int height = getHeight(); mTempRect.top = 0; mTempRect.bottom = height; if (down) { int count = getChildCount(); if (count > 0) { View view = getChildAt(count - 1); mTempRect.bottom = view.getBottom() + getPaddingBottom(); mTempRect.top = mTempRect.bottom - height; } } return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom); }
From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java
private boolean inChild(int x, int y) { if (getChildCount() > 0) { final int scrollY = getScrollY(); final View child = getChildAt(0); return !(y < child.getTop() - scrollY || y >= child.getBottom() - scrollY || x < child.getLeft() || x >= child.getRight()); }/*from w ww .j a v a 2s .c om*/ return false; }
From source file:com.hmatalonga.greenhub.ui.TaskListActivity.java
/** * We're gonna setup another ItemDecorator that will draw the red background in the empty space while the items are animating to thier new positions * after an item is removed.//from ww w. j a v a 2 s. c o m */ private void setUpAnimationDecoratorHelper() { mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() { // we want to cache this and not allocate anything repeatedly in the onDraw method Drawable background; boolean initiated; private void init() { background = new ColorDrawable(Color.DKGRAY); initiated = true; } @Override public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (!initiated) { init(); } // only if animation is in progress if (parent.getItemAnimator().isRunning()) { // some items might be animating down and some items might be animating up to close the gap left by the removed item // this is not exclusive, both movement can be happening at the same time // to reproduce this leave just enough items so the first one and the last one would be just a little off screen // then remove one from the middle // find first child with translationY > 0 // and last one with translationY < 0 // we're after a rect that is not covered in recycler-view views at this point in time View lastViewComingDown = null; View firstViewComingUp = null; // this is fixed int left = 0; int right = parent.getWidth(); // this we need to find out int top = 0; int bottom = 0; // find relevant translating views int childCount = parent.getLayoutManager().getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getLayoutManager().getChildAt(i); if (child.getTranslationY() < 0) { // view is coming down lastViewComingDown = child; } else if (child.getTranslationY() > 0) { // view is coming up if (firstViewComingUp == null) { firstViewComingUp = child; } } } if (lastViewComingDown != null && firstViewComingUp != null) { // views are coming down AND going up to fill the void top = lastViewComingDown.getBottom() + (int) lastViewComingDown.getTranslationY(); bottom = firstViewComingUp.getTop() + (int) firstViewComingUp.getTranslationY(); } else if (lastViewComingDown != null) { // views are going down to fill the void top = lastViewComingDown.getBottom() + (int) lastViewComingDown.getTranslationY(); bottom = lastViewComingDown.getBottom(); } else if (firstViewComingUp != null) { // views are coming up to fill the void top = firstViewComingUp.getTop(); bottom = firstViewComingUp.getTop() + (int) firstViewComingUp.getTranslationY(); } background.setBounds(left, top, right, bottom); background.draw(canvas); } super.onDraw(canvas, parent, state); } }); }