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:bw.com.yunifangstore.view.LazyViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;//from w ww.j a va 2s. c o m populate(); mInLayout = false; final int count = getChildCount(); final int width = r - l; for (int i = 0; i < count; i++) { View child = getChildAt(i); ItemInfo ii; if (child.getVisibility() != GONE && (ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * ii.position; int childLeft = getPaddingLeft() + loff; int childTop = getPaddingTop(); if (DEBUG) Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } mFirstLayout = false; }
From source file:com.android.systemui.qs.QSDragPanel.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int w = getWidth(); mQsPanelTop.layout(0, 0, w, mQsPanelTop.getMeasuredHeight()); int viewPagerBottom = mQsPanelTop.getMeasuredHeight() + mViewPager.getMeasuredHeight(); // view pager laid out from top of brightness view to bottom to page through settings mViewPager.layout(0, 0, w, viewPagerBottom); mDetail.layout(0, 0, w, mDetail.getMeasuredHeight()); if (mFooter.hasFooter()) { View footer = mFooter.getView(); footer.layout(0, getMeasuredHeight() - footer.getMeasuredHeight(), footer.getMeasuredWidth(), getMeasuredHeight());//w ww.jav a2 s .c o m } if (!isShowingDetail() && !isClosingDetail()) { mQsPanelTop.bringToFront(); } // layout page indicator inside viewpager inset mPageIndicator.layout(0, b - mPageIndicatorHeight, w, b); }
From source file:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;/*from www . jav a 2s . c o m*/ populate(); mInLayout = false; final int count = getChildCount(); final int width = r - l; for (int i = 0; i < count; i++) { View child = getChildAt(i); ItemInfo ii; if (child.getVisibility() != GONE && (ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * ii.position; int childLeft = getPaddingLeft() + loff; int childTop = getPaddingTop(); if (DEBUG) { Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight()); } child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } mFirstLayout = false; }
From source file:com.quran.labs.androidquran.widgets.SlidingUpPanelLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int paddingLeft = getPaddingLeft(); final int paddingTop = getPaddingTop(); final int slidingTop = getSlidingTop(); final int childCount = getChildCount(); if (mFirstLayout) { switch (mSlideState) { case EXPANDED: mSlideOffset = mCanSlide ? 0.f : 1.f; break; case ANCHORED: mSlideOffset = mCanSlide ? mAnchorPoint : 1.f; break; default:/*w ww. j ava2 s . co m*/ mSlideOffset = 1.f; break; } } for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int childHeight = child.getMeasuredHeight(); if (lp.slideable) { mSlideRange = childHeight - mPanelHeight; } int childTop; if (mIsSlidingUp) { childTop = lp.slideable ? slidingTop + (int) (mSlideRange * mSlideOffset) : paddingTop; } else { childTop = lp.slideable ? slidingTop - (int) (mSlideRange * mSlideOffset) : paddingTop; if (!lp.slideable && !mOverlayContent) { childTop += mPanelHeight; } } final int childBottom = childTop + childHeight; final int childLeft = paddingLeft; final int childRight = childLeft + child.getMeasuredWidth(); child.layout(childLeft, childTop, childRight, childBottom); } if (mFirstLayout) { updateObscuredViewVisibility(); } mFirstLayout = false; }
From source file:android.support.v7.widget.Toolbar.java
private int layoutChildLeft(View child, int left, int[] collapsingMargins, int alignmentHeight) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int l = lp.leftMargin - collapsingMargins[0]; left += Math.max(0, l);/* w ww . jav a 2 s . co m*/ collapsingMargins[0] = Math.max(0, -l); final int top = getChildTop(child, alignmentHeight); final int childWidth = child.getMeasuredWidth(); child.layout(left, top, left + childWidth, top + child.getMeasuredHeight()); left += childWidth + lp.rightMargin; return left; }
From source file:android.support.v7.widget.Toolbar.java
private int layoutChildRight(View child, int right, int[] collapsingMargins, int alignmentHeight) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int r = lp.rightMargin - collapsingMargins[1]; right -= Math.max(0, r);//from www .jav a2 s . c om collapsingMargins[1] = Math.max(0, -r); final int top = getChildTop(child, alignmentHeight); final int childWidth = child.getMeasuredWidth(); child.layout(right - childWidth, top, right, top + child.getMeasuredHeight()); right -= childWidth + lp.leftMargin; return right; }
From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java
/** * 12-03 22:59:19.686: I/BottomDrawerLayout(12480): onLayout() -- left = 0 * -- top = 0 -- right = 1080 -- b = 1675 12-03 22:59:19.686: * I/BottomDrawerLayout(12480): onLayout() -- childWidth = 750 -- * childHeight = 1675 -- lp.onScreen = 0.0 12-03 22:59:19.686: * I/BottomDrawerLayout(12480): onLayout() -- childLeft = -750 -- newOffset * = 0.0 12-03 22:59:19.686: I/BottomDrawerLayout(12480): onLayout() -- * childWidth = 750 -- childHeight = 1675 -- lp.onScreen = 0.0 12-03 * 22:59:19.686: I/BottomDrawerLayout(12480): onLayout() -- childLeft = 1080 * -- newOffset = 0.0/*from w w w. ja v a 2 s .co m*/ */ @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { Log.i(TAG, "onLayout() -- left = " + l + " -- top = " + t + " -- right = " + r + " -- b = " + b); mInLayout = true; final int width = r - l;// final int height = b - t;// final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (isContentView(child)) { child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight()); } else { // ?view final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); // Log.i(TAG, "onLayout() -- childWidth = " + childWidth + // " -- childHeight = " + childHeight // + " -- lp.onScreen = " + lp.onScreen); int childLeft = 0;// int childTop = 0;// float newOffset = 0;// switch (getDrawerViewAbsoluteGravity(child)) { case Gravity.LEFT: if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { // Log.i(TAG, "onLayout() -- 1"); childLeft = -childWidth + (int) (childWidth * lp.onScreen); newOffset = (float) (childWidth + childLeft) / childWidth;// ? } break; case Gravity.RIGHT: if (checkDrawerViewAbsoluteGravity(child, Gravity.RIGHT)) { // Log.i(TAG, "onLayout() -- 2"); childLeft = width - (int) (childWidth * lp.onScreen); newOffset = (float) (width - childLeft) / childWidth;// ? } break; case Gravity.TOP: if (checkDrawerViewAbsoluteGravity(child, Gravity.TOP)) { // Log.i(TAG, "onLayout() -- 3"); childTop = -childHeight + (int) (childHeight * lp.onScreen); newOffset = (float) (childHeight + childTop) / childHeight;// ? } break; case Gravity.BOTTOM: if (checkDrawerViewAbsoluteGravity(child, Gravity.BOTTOM)) { // Log.i(TAG, "onLayout() -- 4"); childTop = height - (int) (childHeight * lp.onScreen); newOffset = (float) (height - childTop) / childHeight;// ? } break; default: childTop = height - (int) (childHeight * lp.onScreen); newOffset = (float) (height - childTop) / childHeight;// ? break; } // ///////////////////////////////////////// // Log.i(TAG, "onLayout() -- childLeft = " + childLeft + // " -- newOffset = " + newOffset); final boolean changeOffset = newOffset != lp.onScreen; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (vgrav) { // case Gravity.TOP: { // Log.i(TAG, "onLayout() -- Gravity.TOP"); // child.layout(childLeft, lp.topMargin, childLeft + childWidth, // lp.topMargin + childHeight); // break; // } // case Gravity.BOTTOM: { // Log.i(TAG, "onLayout() -- Gravity.BOTTOM"); // child.layout(childLeft, height - lp.bottomMargin - // child.getMeasuredHeight(), childLeft // + childWidth, height - lp.bottomMargin); // break; // } case Gravity.CENTER_VERTICAL: { // Log.i(TAG, "onLayout() -- Gravity.CENTER_VERTICAL"); int childTop_cv = (height - childHeight) / 2; // Offset for margins. If things don't fit right because of // bad measurement before, oh well. if (childTop_cv < lp.topMargin) { childTop_cv = lp.topMargin; } else if (childTop_cv + childHeight > height - lp.bottomMargin) { childTop_cv = height - lp.bottomMargin - childHeight; } child.layout(childLeft, childTop_cv, childLeft + childWidth, childTop_cv + childHeight); break; } } // ///////////////////////////////////////// if (changeOffset) { setDrawerViewOffset(child, newOffset); } final int newVisibility = lp.onScreen > 0 ? VISIBLE : INVISIBLE; if (child.getVisibility() != newVisibility) { child.setVisibility(newVisibility); } } } mInLayout = false; mFirstLayout = false; }
From source file:com.android.dialer.widget.OverlappingPaneLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); final int height = b - t; final int paddingTop = getPaddingTop(); final int paddingBottom = getPaddingBottom(); final int paddingLeft = getPaddingLeft(); final int childCount = getChildCount(); int yStart = paddingTop; int nextYStart = yStart; if (mFirstLayout) { mSlideOffset = mCanSlide && mPreservedOpenState ? 1.f : 0.f; }//from w w w . j a v a 2s .c om for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int childHeight = child.getMeasuredHeight(); if (lp.slideable) { final int margin = lp.topMargin + lp.bottomMargin; final int range = Math.min(nextYStart, height - paddingBottom - mOverhangSize) - yStart - margin; mSlideRange = range; final int lpMargin = lp.topMargin; final int pos = (int) (range * mSlideOffset); yStart += pos + lpMargin; updateSlideOffset(pos); } else { yStart = nextYStart; } final int childTop = yStart; final int childBottom = childTop + childHeight; final int childLeft = paddingLeft; final int childRight = childLeft + child.getMeasuredWidth(); child.layout(childLeft, childTop, childRight, childBottom); nextYStart += child.getHeight(); } if (mFirstLayout) { updateObscuredViewsVisibility(mSlideableView); } mFirstLayout = false; }
From source file:com.vincestyling.traversaless.ViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;/*ww w. ja va 2 s. com*/ populate(); mInLayout = false; final int count = getChildCount(); final int width = r - l; for (int i = 0; i < count; i++) { View child = getChildAt(i); ItemInfo ii; if (child.getVisibility() != GONE && (ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * (mDisableTraversal ? ii.tmpPosition : ii.position); int childLeft = getPaddingLeft() + loff; int childTop = getPaddingTop(); if (DEBUG) Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } mFirstLayout = false; }
From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int paddingLeft = getPaddingLeft(); final int paddingTop = getPaddingTop(); final int childCount = getChildCount(); if (mFirstLayout) { switch (mSlideState) { case EXPANDED: mSlideOffset = 1.0f;/*from w w w. j a va 2s .c o m*/ break; case ANCHORED: mSlideOffset = mAnchorPoint; break; case HIDDEN: int newTop = computePanelTopPosition(0.0f) + (mIsSlidingUp ? +mPanelHeight : -mPanelHeight); mSlideOffset = computeSlideOffset(newTop); break; default: mSlideOffset = 0.f; break; } } for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); // Always layout the sliding view on the first layout if (child.getVisibility() == GONE && (i == 0 || mFirstLayout)) { continue; } final int childHeight = child.getMeasuredHeight(); int childTop = paddingTop; if (child == mSlideableView) { childTop = computePanelTopPosition(mSlideOffset); } if (!mIsSlidingUp) { if (child == mMainView && !mOverlayContent) { childTop = computePanelTopPosition(mSlideOffset) + mSlideableView.getMeasuredHeight(); } } final int childBottom = childTop + childHeight; final int childLeft = paddingLeft + lp.leftMargin; final int childRight = childLeft + child.getMeasuredWidth(); child.layout(childLeft, childTop, childRight, childBottom); } if (mFirstLayout) { updateObscuredViewVisibility(); } applyParallaxForCurrentSlideOffset(); mFirstLayout = false; }