@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // DON'T CALL `setContentView`, // we are replacing that line with this code: ViewGroup wrapperView = setContentViewWithWrapper(R.layout.activity_layout); // Now, because the wrapper view contains the entire screen (including the notification bar // which is above the ActionBar) I think you'll find it useful to know the exact Y where the // action bar is located. // You can use something like that: ViewGroup actionBar = (ViewGroup)((LinearLayout)wrapperView.getChildAt(0)).getChildAt(0); int topOffset = actionBar.getTop(); // Now, if you'll want to add a view: // 1. Create new view // 2. Set padding top - use "topOffset" // 3. Add the view to "wrapperView" // 4. The view should be set at front. if not - try calling to "bringToFront()" }
private int getEdgesTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result |= EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result |= EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result |= EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result |= EDGE_BOTTOM; return result; } }
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) { if (outRect == null) { outRect = new Rect(); } if (child == null) { outRect.set(0, 0, 0, 0); return outRect; } outRect.left = child.getLeft(); outRect.right = child.getRight(); outRect.top = child.getTop(); outRect.bottom = child.getBottom(); ViewParent parent = child.getParent(); while (parent instanceof ViewGroup && parent != this) { final ViewGroup group = (ViewGroup) parent; outRect.left += group.getLeft(); outRect.right += group.getRight(); outRect.top += group.getTop(); outRect.bottom += group.getBottom(); parent = group.getParent(); } return outRect; }
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) { if (outRect == null) { outRect = new Rect(); } if (child == null) { outRect.set(0, 0, 0, 0); return outRect; } outRect.left = child.getLeft(); outRect.right = child.getRight(); outRect.top = child.getTop(); outRect.bottom = child.getBottom(); ViewParent parent = child.getParent(); while (parent instanceof ViewGroup && parent != this) { final ViewGroup group = (ViewGroup) parent; outRect.left += group.getLeft(); outRect.right += group.getRight(); outRect.top += group.getTop(); outRect.bottom += group.getBottom(); parent = group.getParent(); } return outRect; }
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) { if (outRect == null) { outRect = new Rect(); } if (child == null) { outRect.set(0, 0, 0, 0); return outRect; } outRect.left = child.getLeft(); outRect.right = child.getRight(); outRect.top = child.getTop(); outRect.bottom = child.getBottom(); ViewParent parent = child.getParent(); while (parent instanceof ViewGroup && parent != this) { final ViewGroup group = (ViewGroup) parent; outRect.left += group.getLeft(); outRect.right += group.getRight(); outRect.top += group.getTop(); outRect.bottom += group.getBottom(); parent = group.getParent(); } return outRect; }
private int getEdgesTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result |= EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result |= EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result |= EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result |= EDGE_BOTTOM; return result; }
private int getEdgeTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result = EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result = EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result = EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result = EDGE_BOTTOM; return result; } }
private int getEdgeTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result = EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result = EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result = EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result = EDGE_BOTTOM; return result; } }
private int getEdgeTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result = EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result = EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result = EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result = EDGE_BOTTOM; return result; } }
bean.windowWidth = parent.getWidth(); bean.windowHeight = parent.getHeight(); bean.titleHeight = parent.getTop(); if (exposeView == null) { exposeView = new CirleExposeView(activity); (int) (bean.targetHeight * bean.scale)); ivTempParams.setMargins((int) (bean.originRect.left + (bean.originWidth / 2 - bean.targetWidth * bean.scale / 2)) , bean.originRect.top - (parent.getTop() + bean.statusBarHeight), 0, 0); bean.translationY = bean.originRect.top + (int) (bean.targetHeight * bean.scale) / 2 - bean.targetRect.top - bean.targetHeight / 2; bean.translationX = bean.originRect.left + bean.originWidth / 2 - bean.targetRect.left - bean.targetWidth / 2;
final ViewGroup mountedView = mock(ViewGroup.class); when(mountedView.getLeft()).thenReturn(0); when(mountedView.getTop()).thenReturn(0); when(mountedView.getRight()).thenReturn(100); when(mountedView.getBottom()).thenReturn(100);
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) { if (outRect == null) { outRect = new Rect(); } if (child == null) { outRect.set(0, 0, 0, 0); return outRect; } outRect.left = child.getLeft(); outRect.right = child.getRight(); outRect.top = child.getTop(); outRect.bottom = child.getBottom(); ViewParent parent = child.getParent(); while (parent instanceof ViewGroup && parent != this) { final ViewGroup group = (ViewGroup) parent; outRect.left += group.getLeft(); outRect.right += group.getRight(); outRect.top += group.getTop(); outRect.bottom += group.getBottom(); parent = group.getParent(); } return outRect; }
private int getEdgesTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result |= EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result |= EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result |= EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result |= EDGE_BOTTOM; return result; } }
private int getEdgeTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result = EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result = EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result = EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result = EDGE_BOTTOM; return EDGE_LEFT; } }
private int getEdgeTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result = EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result = EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result = EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result = EDGE_BOTTOM; return result; } }
int clickY = (int) (event.getY() - mHandleLayout.getTop());
private void drawDivider(int expPosition, Canvas canvas) { final Drawable divider = getDivider(); final int dividerHeight = getDividerHeight(); // Log.d("mobeta", "div="+divider+" divH="+dividerHeight); if (divider != null && dividerHeight != 0) { final ViewGroup expItem = (ViewGroup) getChildAt(expPosition - getFirstVisiblePosition()); if (expItem != null) { final int l = getPaddingLeft(); final int r = getWidth() - getPaddingRight(); final int t; final int b; final int childHeight = expItem.getChildAt(0).getHeight(); if (expPosition > mSrcPos) { t = expItem.getTop() + childHeight; b = t + dividerHeight; } else { b = expItem.getBottom() - childHeight; t = b - dividerHeight; } // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b); // Have to clip to support ColorDrawable on <= Gingerbread canvas.save(); canvas.clipRect(l, t, r, b); divider.setBounds(l, t, r, b); divider.draw(canvas); canvas.restore(); } } }
ScrollView mScrollView = (ScrollView) findViewById(R.id.scroll_view); mScrollView.post(new Runnable() { public void run() { Button btn = (Button) findViewById(k); ViewGroup vg =(ViewGroup)btn.getParent(); mScrollView.smoothScrollTo(0,vg.getTop()); }}); }
private int getEdgesTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result |= EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result |= EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result |= EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result |= EDGE_BOTTOM; return result; }
private int getEdgesTouched(int x, int y) { int result = 0; if (x < mParentView.getLeft() + mEdgeSize) result |= EDGE_LEFT; if (y < mParentView.getTop() + mEdgeSize) result |= EDGE_TOP; if (x > mParentView.getRight() - mEdgeSize) result |= EDGE_RIGHT; if (y > mParentView.getBottom() - mEdgeSize) result |= EDGE_BOTTOM; return result; } }