List of usage examples for android.view View layout
@SuppressWarnings({ "unchecked" }) public void layout(int l, int t, int r, int b)
This is the second phase of the layout mechanism.
From source file:net.microtrash.clapcamera.Preview.java
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { Log.d(TAG, "onSizeChanged() " + w + " " + h); fullWidth = w;/*from w w w . jav a2s. com*/ fullHeight = h; if (fullWidth < fullHeight) { int tmp = fullHeight; fullHeight = fullWidth; fullWidth = tmp; Log.d(TAG, "switched:" + fullWidth + "x" + fullHeight); } else { Log.d(TAG, "fullSize:" + fullWidth + "x" + fullHeight); } if (this.camera != null) { this.setCameraPreviewSize(); this.setCameraPictureSize(); if (getChildCount() > 0) { final View child = getChildAt(0); Log.d(TAG, "r:" + this.getPreviewRight() + " l:" + this.getPreviewLeft() + " b:" + this.getPreviewBottom() + " t:" + this.getPreviewTop()); child.layout(this.getPreviewLeft(), this.getPreviewTop(), this.getPreviewRight(), this.getPreviewBottom()); cb.previewReady(getPreviewLeft(), getPreviewTop(), getPreviewRight() - getPreviewLeft(), getPreviewBottom() - getPreviewTop(), getBestPictureSize().width, getBestPictureSize().height, (int) downscalingFactor, allResolutions); } } super.onSizeChanged(w, h, oldw, oldh); }
From source file:xiaofei.library.gridlayout.GridLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int count = getChildCount(); final int paddingLeft = getPaddingLeft(); final int paddingRight = getPaddingRight(); final int paddingTop = getPaddingTop(); final int paddingBottom = getPaddingBottom(); final int numRows = mNumRows; final int numColumns = mNumColumns; final int horizontalSpacing = mHorizontalSpacing; final int verticalSpacing = mVerticalSpacing; final int childWidth = (getMeasuredWidth() - paddingLeft - paddingRight - horizontalSpacing * (numColumns - 1)) / numColumns; final int childHeight = (getMeasuredHeight() - paddingTop - paddingBottom - verticalSpacing * (numRows - 1)) / numRows;// w ww. ja v a2 s.c o m for (int i = 0; i < count; ++i) { final View child = getChildAt(i); final int row = i / numColumns; final int column = i % numColumns; if (child.getVisibility() != View.GONE) { final int childLeft = paddingLeft + column * (childWidth + horizontalSpacing); final int childTop = paddingTop + row * (childHeight + verticalSpacing); final int tmpWidth = Math.max(childWidth, child.getMeasuredWidth()); final int tmpHeight = Math.max(childHeight, child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + tmpWidth, childTop + tmpHeight); } } }
From source file:android.support.v7.widget.ActionBarContainer.java
@Override public void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); final View tabContainer = mTabContainer; final boolean hasTabs = tabContainer != null && tabContainer.getVisibility() != GONE; if (tabContainer != null && tabContainer.getVisibility() != GONE) { final int containerHeight = getMeasuredHeight(); final LayoutParams lp = (LayoutParams) tabContainer.getLayoutParams(); final int tabHeight = tabContainer.getMeasuredHeight(); tabContainer.layout(l, containerHeight - tabHeight - lp.bottomMargin, r, containerHeight - lp.bottomMargin); }/*from w w w. j av a2s .c o m*/ boolean needsInvalidate = false; if (mIsSplit) { if (mSplitBackground != null) { mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); needsInvalidate = true; } } else { if (mBackground != null) { if (mActionBarView.getVisibility() == View.VISIBLE) { mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(), mActionBarView.getRight(), mActionBarView.getBottom()); } else if (mContextView != null && mContextView.getVisibility() == View.VISIBLE) { mBackground.setBounds(mContextView.getLeft(), mContextView.getTop(), mContextView.getRight(), mContextView.getBottom()); } else { mBackground.setBounds(0, 0, 0, 0); } needsInvalidate = true; } mIsStacked = hasTabs; if (hasTabs && mStackedBackground != null) { mStackedBackground.setBounds(tabContainer.getLeft(), tabContainer.getTop(), tabContainer.getRight(), tabContainer.getBottom()); needsInvalidate = true; } } if (needsInvalidate) { invalidate(); } }
From source file:com.example.expand.test.testfeature.view.SwipeRefreshLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); // mProgressBar.setBounds(0, 0, width, mProgressBarHeight); if (getChildCount() == 0) { return;/*w ww . j av a2 s . c o m*/ } final View child = getChildAt(0); final int childLeft = getPaddingLeft(); final int childTop = mCurrentTargetOffsetTop + getPaddingTop(); final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); }
From source file:typical_if.android.SwipeRefreshLayout.SwipeRefreshLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); // mProgressBar.setBounds(0, 0, width, mProgressBarHeight); mProgressBar.setBounds(0, 0, width, ItemDataSetter.setInDp(48) + mProgressBarHeight); if (getChildCount() == 0) { return;/* w ww. j a v a 2s . c om*/ } final View child = getChildAt(0); final int childLeft = getPaddingLeft(); final int childTop = mCurrentTargetOffsetTop + getPaddingTop(); final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); }
From source file:com.android.mail.browse.ConversationItemView.java
private static void layoutViewExactly(View v, int w, int h) { v.measure(makeExactSpecForSize(w), makeExactSpecForSize(h)); v.layout(0, 0, w, h); }
From source file:cn.bvin.app.swiperefresh.OldSwipeRefreshLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); mProgressBar.setBounds(0, 0, width, mProgressBarHeight); if (getChildCount() == 0) { return;/* ww w.j a va 2 s .c om*/ } final View child = getChildAt(0); final int childLeft = getPaddingLeft(); final int childTop = mCurrentTargetOffsetTop + getPaddingTop(); final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); }
From source file:com.taobao.weex.ui.view.listview.BaseBounceView.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { View child0 = getChildAt(0); int paddingLeft, paddingTop, childRight; paddingLeft = getPaddingLeft();//from ww w .j a v a 2s . co m paddingTop = getPaddingTop(); childRight = r - l - getPaddingRight(); if (child0 != null) { child0.layout(paddingLeft, paddingTop, childRight, b - t - paddingTop); } View child1 = getChildAt(1); if (child1 != null) { int h = child1.getMeasuredHeight(); child1.layout(paddingLeft, -h, childRight, 0); } View child2 = getChildAt(2); if (child2 != null) { int h = child2.getMeasuredHeight(); child2.layout(paddingLeft, b, childRight, b + h); } }
From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = getMeasuredWidth(); int height = getMeasuredHeight(); if (getChildCount() == 0) return;// w w w.j a v a 2s . c o m View child = getChildAt(0); int childWidth = width - getPaddingLeft() - getPaddingRight(); int childHeight = height - getPaddingTop() - getPaddingBottom(); int childLeft = getPaddingLeft(); int childTop = getPaddingTop(); int childRight = childLeft + childWidth; int childBottom = childTop + childHeight; child.layout(childLeft, childTop, childRight, childBottom); }
From source file:am.widget.tabstrip.HorizontalLinearTabStripLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int paddingStart = ViewCompat.getPaddingStart(this); final int paddingTop = getPaddingTop(); final int childWidth = mChildWidth; final int childHeight = mChildHeight; final boolean show = isShowingDividers(); final int divider = show ? mDivider.getIntrinsicWidth() : 0; final int count = getChildCount(); int start = paddingStart; if (show && (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING) { start += divider;/*from w w w . j av a 2 s .c o m*/ } final boolean middle = (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (i == count - 1) { final int right; if (show && (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END) right = getWidth() - ViewCompat.getPaddingEnd(this) - divider; else right = getWidth() - ViewCompat.getPaddingEnd(this); child.layout(start, paddingTop, right, paddingTop + childHeight); break; } else { child.layout(start, paddingTop, start + childWidth, paddingTop + childHeight); } start += childWidth; if (count % 2 == 0 && i == (count / 2) - 1 && mCenter != null) { start += mCenter.getIntrinsicWidth(); if (show && middle && mCenterAsItem) start = start + divider + divider; } else { if (show && middle) start += divider; } } }