public void configureHeaderView(int groupPosition, int childPosition) { if (mHeaderView == null || mAdapter == null || ((ExpandableListAdapter) mAdapter).getGroupCount() == 0) { return; } int state = mAdapter.getTreeHeaderState(groupPosition, childPosition); switch (state) { case IphoneTreeHeaderAdapter.PINNED_HEADER_GONE: { mHeaderViewVisible = false; break; } case IphoneTreeHeaderAdapter.PINNED_HEADER_VISIBLE: { mAdapter.configureTreeHeader(mHeaderView, groupPosition, childPosition, MAX_ALPHA); if (mHeaderView.getTop() != 0) { mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight); } mHeaderViewVisible = true; break; } case IphoneTreeHeaderAdapter.PINNED_HEADER_PUSHED_UP: { View firstView = getChildAt(0); int bottom = firstView.getBottom(); // intitemHeight = firstView.getHeight(); int headerHeight = mHeaderView.getHeight(); int y; int alpha; if (bottom < headerHeight) { y = (bottom - headerHeight); alpha = MAX_ALPHA * (headerHeight + y) / headerHeight; } else { y = 0; alpha = MAX_ALPHA; } mAdapter.configureTreeHeader(mHeaderView, groupPosition, childPosition, alpha); if (mHeaderView.getTop() != y) { mHeaderView.layout(0, y, mHeaderViewWidth, mHeaderViewHeight + y); } mHeaderViewVisible = true; break; } } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int childCount = getChildCount(); final int parentLeft = getPaddingLeft(); final int parentTop = getPaddingTop(); final int parentRight = r - l - getPaddingRight(); final int parentBottom = b - t - getPaddingBottom(); final int parentWidth = parentRight - parentLeft; final int parentHeight = parentBottom - parentTop; int unpaddedWidth, unpaddedHeight, parentUnpaddedWidth, parentUnpaddedHeight; int childPaddingLeft, childPaddingTop, childPaddingRight, childPaddingBottom; for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } // Fit and center the child within the parent. Make sure not to consider padding // as part of the child's aspect ratio. childPaddingLeft = child.getPaddingLeft(); childPaddingTop = child.getPaddingTop(); childPaddingRight = child.getPaddingRight(); childPaddingBottom = child.getPaddingBottom(); unpaddedWidth = child.getMeasuredWidth() - childPaddingLeft - childPaddingRight; unpaddedHeight = child.getMeasuredHeight() - childPaddingTop - childPaddingBottom; parentUnpaddedWidth = parentWidth - childPaddingLeft - childPaddingRight; parentUnpaddedHeight = parentHeight - childPaddingTop - childPaddingBottom; if (parentUnpaddedWidth * unpaddedHeight > parentUnpaddedHeight * unpaddedWidth) { // The child view should be left/right letterboxed. final int scaledChildWidth = unpaddedWidth * parentUnpaddedHeight / unpaddedHeight + childPaddingLeft + childPaddingRight; child.layout( parentLeft + (parentWidth - scaledChildWidth) / 2, parentTop, parentRight - (parentWidth - scaledChildWidth) / 2, parentBottom); } else { // The child view should be top/bottom letterboxed. final int scaledChildHeight = unpaddedHeight * parentUnpaddedWidth / unpaddedWidth + childPaddingTop + childPaddingBottom; child.layout( parentLeft, parentTop + (parentHeight - scaledChildHeight) / 2, parentRight, parentTop + (parentHeight + scaledChildHeight) / 2); } } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { inLayout = true; final int width = r - l; 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(); try { if (drawerLayout != child) { child.layout( lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight()); } else { child.layout( -child.getMeasuredWidth() + (int) drawerPosition, lp.topMargin, (int) drawerPosition, lp.topMargin + child.getMeasuredHeight()); } } catch (Exception e) { FileLog.e("tmessages", e); } } inLayout = false; }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mDragRange = getHeight() - mTitle.getHeight() - getPaddingTop(); mTitle.layout(0, mTop, r, mTop + mTitle.getMeasuredHeight()); mItemsField.layout(0, mTop + mTitle.getMeasuredHeight(), r, mTop + b); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int childCount = getChildCount(); int autualWidth = r - l; // int x = SIDE_MARGIN;// 横坐标开始 int x = 0; // 横坐标开始 int y = 0; // 纵坐标开始 int rows = 1; for (int i = 0; i < childCount; i++) { View view = getChildAt(i); // view.setBackgroundColor(Color.GREEN); int width = view.getMeasuredWidth(); int height = view.getMeasuredHeight(); x += width + TEXT_MARGIN; if (x > autualWidth) { x = width + SIDE_MARGIN; rows++; } y = rows * (height + TEXT_MARGIN); if (i == 0) { view.layout(x - width - TEXT_MARGIN, y - height, x - TEXT_MARGIN, y); } else { view.layout(x - width, y - height, x, y); } } };
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); LogUtils.d("onLayout mHolder.mOffsetY=" + mHolder.mOffsetY); mFootHeight = ((IFooterCallBack) mFooterView).getFooterHeight(); int childCount = getChildCount(); int top = getPaddingTop() + mHolder.mOffsetY; int adHeight = 0; for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child.getVisibility() == View.VISIBLE) { if (i == 0) { adHeight = child.getMeasuredHeight() - mHeaderViewHeight; // 通过把headerview向上移动一个headerview高度的距离来达到隐藏headerview的效果 child.layout(0, top - mHeaderViewHeight, child.getMeasuredWidth(), top + adHeight); top += adHeight; } else if (i == 1) { int childHeight = child.getMeasuredHeight() - adHeight; child.layout(0, top, child.getMeasuredWidth(), childHeight + top); top += childHeight; } else { child.layout(0, top, child.getMeasuredWidth(), child.getMeasuredHeight() + top); top += child.getMeasuredHeight(); } } } }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { // Layout the shutter button. int shutterButtonWidth = mShutterButton.getMeasuredWidth(); int shutterButtonHeight = mShutterButton.getMeasuredHeight(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mCenterX = right - left - Util.dpToPixel(WHEEL_CENTER_TO_SECANT); mCenterY = (bottom - top) / 2; mShutterButton.layout( right - left - shutterButtonWidth, mCenterY - shutterButtonHeight / 2, right - left, mCenterY + shutterButtonHeight / 2); } else { mCenterX = (right - left) / 2; mCenterY = bottom - top - Util.dpToPixel(WHEEL_CENTER_TO_SECANT); mShutterButton.layout( mCenterX - shutterButtonWidth / 2, bottom - top - shutterButtonHeight, mCenterX + shutterButtonWidth / 2, bottom - top); } // Layout the control wheel. mIndicatorControlWheel.layout(0, 0, right - left, bottom - top); }
protected void refreshHeader() { if (mHeaderView == null) { return; } int firstVisiblePos = getFirstVisiblePosition(); int pos = firstVisiblePos + 1; int firstVisibleGroupPos = getPackedPositionGroup(getExpandableListPosition(firstVisiblePos)); int group = getPackedPositionGroup(getExpandableListPosition(pos)); if (DEBUG) { Log.d(TAG, "refreshHeader firstVisibleGroupPos=" + firstVisibleGroupPos); } if (group == firstVisibleGroupPos + 1) { View view = getChildAt(1); if (view == null) { Log.w(TAG, "Warning : refreshHeader getChildAt(1)=null"); return; } if (view.getTop() <= mHeaderHeight) { int delta = mHeaderHeight - view.getTop(); mHeaderView.layout(0, -delta, mHeaderWidth, mHeaderHeight - delta); } else { // TODO : note it, when cause bug, remove it mHeaderView.layout(0, 0, mHeaderWidth, mHeaderHeight); } } else { mHeaderView.layout(0, 0, mHeaderWidth, mHeaderHeight); } if (mHeaderUpdateListener != null) { mHeaderUpdateListener.updatePinnedHeader(mHeaderView, firstVisibleGroupPos); } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mContent.set( getPaddingLeft(), getPaddingTop(), r - l - getPaddingRight(), b - t - getPaddingBottom()); final int width = mContent.width(); final int height = mContent.height(); // no scrolling yet, so tell dimensions to fill exactly mHoriz.setSize(width); mVert.setSize(height); final Rect parentRect = new Rect(); final Rect childRect = new Rect(); for (int i = 0; i < getChildCount(); i++) { final View child = getChildAt(i); final LayoutParams params = (LayoutParams) child.getLayoutParams(); parentRect.set(mContent); if (child instanceof ChartNetworkSeriesView || child instanceof ChartGridView) { // series are always laid out to fill entire graph area // TODO: handle scrolling for series larger than content area Gravity.apply(params.gravity, width, height, parentRect, childRect); child.layout(childRect.left, childRect.top, childRect.right, childRect.bottom); } else if (child instanceof ChartSweepView) { layoutSweep((ChartSweepView) child, parentRect, childRect); child.layout(childRect.left, childRect.top, childRect.right, childRect.bottom); } } }
private void repositionViews() { int left, top, right, bottom, i; left = widths[0] - scrollX; i = firstColumn; for (View view : rowViewList) { right = left + widths[++i]; view.layout(left, 0, right, heights[0]); left = right; } top = heights[0] - scrollY; i = firstRow; for (View view : columnViewList) { bottom = top + heights[++i]; view.layout(0, top, widths[0], bottom); top = bottom; } top = heights[0] - scrollY; i = firstRow; for (List<View> list : bodyViewTable) { bottom = top + heights[++i]; left = widths[0] - scrollX; int j = firstColumn; for (View view : list) { right = left + widths[++j]; view.layout(left, top, right, bottom); left = right; } top = bottom; } invalidate(); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if (changed && getChildCount() > 0) { final View child = getChildAt(0); final int width = r - l; final int height = b - t; int previewWidth = width; int previewHeight = height; // handle orientation if (previewSize != null) { if (getDisplayOrientation() == 90 || getDisplayOrientation() == 270) { previewWidth = previewSize.height; previewHeight = previewSize.width; } else { previewWidth = previewSize.width; previewHeight = previewSize.height; } } boolean useFirstStrategy = (width * previewHeight > height * previewWidth); boolean useFullBleed = getHost().useFullBleedPreview(); if ((useFirstStrategy && !useFullBleed) || (!useFirstStrategy && useFullBleed)) { final int scaledChildWidth = previewWidth * height / previewHeight; child.layout((width - scaledChildWidth) / 2, 0, (width + scaledChildWidth) / 2, height); } else { final int scaledChildHeight = previewHeight * width / previewWidth; child.layout(0, (height - scaledChildHeight) / 2, width, (height + scaledChildHeight) / 2); } } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int width = r - l; final int height = b - t; mContent.layout(0, 0, width - mWidthOffset, height); if (mSecondaryContent != null) mSecondaryContent.layout(0, 0, width - mWidthOffset, height); }
private void measureHeader() { if (mStickiedHeader == null) { return; } int widthMeasureSpec; if (mHeadersIgnorePadding) { widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY); } else { widthMeasureSpec = MeasureSpec.makeMeasureSpec( getWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY); } int heightMeasureSpec = 0; ViewGroup.LayoutParams params = mStickiedHeader.getLayoutParams(); if (params != null && params.height > 0) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(params.height, MeasureSpec.EXACTLY); } else { heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } mStickiedHeader.measure(MeasureSpec.makeMeasureSpec(0, 0), MeasureSpec.makeMeasureSpec(0, 0)); mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec); if (mHeadersIgnorePadding) { mStickiedHeader.layout(getLeft(), 0, getRight(), mStickiedHeader.getMeasuredHeight()); } else { mStickiedHeader.layout( getLeft() + getPaddingLeft(), 0, getRight() - getPaddingRight(), mStickiedHeader.getMeasuredHeight()); } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if (changed && getChildCount() > 0) { final View child = getChildAt(0); final int width = r - l; final int height = b - t; int previewWidth = width; int previewHeight = height; if (mPreviewSize != null) { previewWidth = mPreviewSize.width; previewHeight = mPreviewSize.height; } // Center the child SurfaceView within the parent. if (width * previewHeight > height * previewWidth) { final int scaledChildWidth = previewWidth * height / previewHeight; child.layout((width - scaledChildWidth) / 2, 0, (width + scaledChildWidth) / 2, height); } else { final int scaledChildHeight = previewHeight * width / previewWidth; child.layout(0, (height - scaledChildHeight) / 2, width, (height + scaledChildHeight) / 2); } } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mBgView.layout(l, t, r, b); int dragViewHeight = mHeaderView.getMeasuredHeight(); int dragViewWidth = mHeaderView.getMeasuredWidth(); mDragRange = mContentView.getMeasuredHeight(); // parentViewHeight - // dragViewHeight; if (Constants.hasEnterpriseAccountLoggedIn()) { mTop = 0; } LogUtil.d( TAG, "onLayout:" + "changed:" + changed + ",l:" + l + ",t:" + t + ",r:" + r + ",b:" + b + ",mDragRange" + mDragRange + ",mtop----" + mTop + " drageViewWidth----" + dragViewWidth + " dragViewHeight----" + dragViewHeight); mContentView.layout(0, 0, r, mTop); mHeaderView.layout( 20, mTop + mHeaderView.getPaddingTop(), 20 + dragViewWidth, mTop + dragViewHeight); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { View view = resolveView(); if (view != null) { int width = getMeasuredWidth(); int height = getMeasuredHeight(); @Px int leftLineWidth = leftBorder == BorderMode.LINE ? 1 : leftPageBorder.getIntrinsicWidth(); @Px int rightLineWidth = rightBorder == BorderMode.HIDDEN ? 0 : rightPageBorder.getIntrinsicWidth(); int headerFooterHeight = 0; view.layout( leftLineWidth, headerFooterHeight, width - rightLineWidth, height - headerFooterHeight); if (errorLayout != null) { int errorLayoutWidth = errorLayout.getMeasuredWidth(); int errorLayoutHeight = errorLayout.getMeasuredHeight(); int leftRightOffset = ((width - (leftLineWidth + rightLineWidth)) - errorLayoutWidth) / 2; int topBottomOffset = ((height - 2 * headerFooterHeight) - errorLayoutHeight) / 2; errorLayout.layout( leftLineWidth + leftRightOffset, headerFooterHeight + topBottomOffset, leftLineWidth + leftRightOffset + errorLayoutWidth, headerFooterHeight + topBottomOffset + errorLayoutHeight); } } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int childCount = getChildCount(); if (childCount > 1) { int iconBottom = mIcons.get(0).getMeasuredHeight() + dpi2px(defaultIconPaddingTop); int iconTop = dpi2px(defaultIconPaddingTop) + mSplit.getMeasuredHeight(); for (int i = 0; i < mIcons.size(); i++) { View icon = mIcons.get(i); icon.layout( icon.getMeasuredWidth() * i, iconTop, icon.getMeasuredWidth() * (i + 1), iconBottom); } int titleBottom = getMeasuredHeight() - dpi2px(defaultTitlePaddingBottom); int titleTop = titleBottom - mTitles.get(0).getMeasuredHeight(); for (int i = 0; i < mTitles.size(); i++) { View title = mTitles.get(i); title.layout( title.getMeasuredWidth() * i, titleTop, title.getMeasuredWidth() * (i + 1), titleBottom); } mSplit.layout(0, 0, r, mSplit.getMeasuredHeight()); } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if (!isLayout) { // 这里是第一次进来的时候做一些初始化 refreshView = getChildAt(0); pullableView = getChildAt(1); loadmoreView = getChildAt(2); isLayout = true; initView(); refreshDist = ((ViewGroup) refreshView).getChildAt(0).getMeasuredHeight(); loadmoreDist = ((ViewGroup) loadmoreView).getChildAt(0).getMeasuredHeight(); } // 改变子控件的布局,这里直接用(pullDownY + pullUpY)作为偏移量,这样就可以不对当前状态作区分 refreshView.layout( 0, (int) (pullDownY + pullUpY) - refreshView.getMeasuredHeight(), refreshView.getMeasuredWidth(), (int) (pullDownY + pullUpY)); pullableView.layout( 0, (int) (pullDownY + pullUpY), pullableView.getMeasuredWidth(), (int) (pullDownY + pullUpY) + pullableView.getMeasuredHeight()); loadmoreView.layout( 0, (int) (pullDownY + pullUpY) + pullableView.getMeasuredHeight(), loadmoreView.getMeasuredWidth(), (int) (pullDownY + pullUpY) + pullableView.getMeasuredHeight() + loadmoreView.getMeasuredHeight()); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { // 这里是第一次进来的时候做一些初始化 if (isFirstTimeCallOnLayout) { isFirstTimeCallOnLayout = false; mPullableView = getChildAt(2); if (getChildCount() > 3) throw new IllegalArgumentException( "PullToRefreshLayout should only has one direct child in xml !"); initView(); } refreshDist = ((ViewGroup) refreshView).getChildAt(0).getMeasuredHeight(); loadMoreDist = ((ViewGroup) loadMoreView).getChildAt(0).getMeasuredHeight(); // 改变子控件的布局,这里直接用(pullDownY + pullUpY)作为偏移量,这样就可以不对当前状态作区分 refreshView.layout( 0, (int) (pullDownY + pullUpY) - refreshView.getMeasuredHeight(), refreshView.getMeasuredWidth(), (int) (pullDownY + pullUpY)); mPullableView.layout( 0, (int) (pullDownY + pullUpY), mPullableView.getMeasuredWidth(), (int) (pullDownY + pullUpY) + mPullableView.getMeasuredHeight()); loadMoreView.layout( 0, (int) (pullDownY + pullUpY) + mPullableView.getMeasuredHeight(), loadMoreView.getMeasuredWidth(), (int) (pullDownY + pullUpY) + mPullableView.getMeasuredHeight() + loadMoreView.getMeasuredHeight()); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { // 布局卡片view int size = viewList.size(); for (int i = 0; i < size; i++) { View viewItem = viewList.get(i); int childHeight = viewItem.getMeasuredHeight(); viewItem.layout(left, top, right, top + childHeight); int offset = yOffsetStep * i; float scale = 1 - SCALE_STEP * i; if (i > 2) { // 备用的view offset = yOffsetStep * 2; scale = 1 - SCALE_STEP * 2; } viewItem.offsetTopAndBottom(offset); viewItem.setScaleX(scale); viewItem.setScaleY(scale); } // 布局底部按钮的View if (null != bottomLayout) { int layoutTop = viewList.get(0).getMeasuredHeight() + bottomMarginTop; bottomLayout.layout(left, layoutTop, right, layoutTop + bottomLayout.getMeasuredHeight()); } // 初始化一些中间参数 initCenterViewX = viewList.get(0).getLeft(); initCenterViewY = viewList.get(0).getTop(); childWith = viewList.get(0).getMeasuredWidth(); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { FrameLayout.LayoutParams lp = (LayoutParams) mContentView.getLayoutParams(); int lGap = getPaddingLeft() + lp.leftMargin; int tGap = getPaddingTop() + lp.topMargin; mContentView.layout( lGap, tGap, lGap + (OVER_API_11 ? mContentView.getMeasuredWidthAndState() : mContentView.getMeasuredWidth()), tGap + (OVER_API_11 ? mContentView.getMeasuredHeightAndState() : mContentView.getMeasuredHeight())); lp = (LayoutParams) mMenuView.getLayoutParams(); tGap = getPaddingTop() + lp.topMargin; if (mSwipeDirection == SwipeMenuRecyclerView.DIRECTION_LEFT) { mMenuView.layout( getMeasuredWidth(), tGap, getMeasuredWidth() + (OVER_API_11 ? mMenuView.getMeasuredWidthAndState() : mMenuView.getMeasuredWidth()), tGap + mMenuView.getMeasuredHeightAndState()); } else { mMenuView.layout( -(OVER_API_11 ? mMenuView.getMeasuredWidthAndState() : mMenuView.getMeasuredWidth()), tGap, 0, tGap + mMenuView.getMeasuredHeightAndState()); } }
private void layoutChildren() { int offsetX = mPtrIndicator.getCurrentPosY(); int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); if (mHeaderView != null) { MarginLayoutParams lp = (MarginLayoutParams) mHeaderView.getLayoutParams(); final int left = paddingLeft + lp.leftMargin; final int top = paddingTop + lp.topMargin + offsetX - mHeaderHeight; final int right = left + mHeaderView.getMeasuredWidth(); final int bottom = top + mHeaderView.getMeasuredHeight(); mHeaderView.layout(left, top, right, bottom); if (DEBUG && DEBUG_LAYOUT) { PtrCLog.d(LOG_TAG, "onLayout header: %s %s %s %s", left, top, right, bottom); } } if (mContent != null) { if (isPinContent()) { offsetX = 0; } MarginLayoutParams lp = (MarginLayoutParams) mContent.getLayoutParams(); final int left = paddingLeft + lp.leftMargin; final int top = paddingTop + lp.topMargin + offsetX; final int right = left + mContent.getMeasuredWidth(); final int bottom = top + mContent.getMeasuredHeight(); if (DEBUG && DEBUG_LAYOUT) { PtrCLog.d(LOG_TAG, "onLayout content: %s %s %s %s", left, top, right, bottom); } mContent.layout(left, top, right, bottom); } }
@Override public void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE; if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { final int containerHeight = getMeasuredHeight(); final int tabHeight = mTabContainer.getMeasuredHeight(); if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) { // Not showing home, put tabs on top. final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child == mTabContainer) { continue; } if (!mActionBarView.isCollapsed()) { child.offsetTopAndBottom(tabHeight); } } mTabContainer.layout(l, 0, r, tabHeight); } else { mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight); } } boolean needsInvalidate = false; if (mIsSplit) { if (mSplitBackground != null) { mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); needsInvalidate = true; } } else { if (mBackground != null) { mBackground.setBounds( mActionBarView.getLeft(), mActionBarView.getTop(), mActionBarView.getRight(), mActionBarView.getBottom()); needsInvalidate = true; } if ((mIsStacked = hasTabs && mStackedBackground != null)) { mStackedBackground.setBounds( mTabContainer.getLeft(), mTabContainer.getTop(), mTabContainer.getRight(), mTabContainer.getBottom()); needsInvalidate = true; } } if (needsInvalidate) { invalidate(); } }
public int a(View view, int i, int i2, int i3, boolean z) { int measuredWidth = view.getMeasuredWidth(); int measuredHeight = view.getMeasuredHeight(); int i4 = ((i3 - measuredHeight) / 2) + i2; if (z) { view.layout(i - measuredWidth, i4, i, measuredHeight + i4); } else { view.layout(i, i4, i + measuredWidth, measuredHeight + i4); } return z ? -measuredWidth : measuredWidth; }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int width = r - l; final int height = b - t; final View leftView = mLeftView; final View mainView = mMainView; final View rightView = mRightView; int leftViewWidth = leftView.getMeasuredWidth(); int leftViewHeight = leftView.getMeasuredHeight(); int mainViewWidth = mainView.getMeasuredWidth(); int mainViewHeight = mainView.getMeasuredHeight(); int rightViewWidth = rightView.getMeasuredWidth(); int rightViewHeight = rightView.getMeasuredHeight(); int leftViewLeft = 0; int leftViewTop = 0; int mainViewLeft = 0; int mainViewTop = 0; int rightViewLeft = 0; int rightViewTop = 0; switch (mCurrentConfiguration) { case CONFIG_MAIN_ONLY: break; case CONFIG_LEFT_OPEN: mainViewLeft = leftViewWidth; break; case CONFIG_RIGHT_OPEN: rightViewLeft = (int) mRightViewLeftPadding; mainViewLeft = -rightViewWidth; break; } leftView.layout( leftViewLeft, leftViewTop, leftViewLeft + leftViewWidth, leftViewTop + leftViewHeight); mainView.layout( mainViewLeft, mainViewTop, mainViewLeft + mainViewWidth, mainViewTop + mainViewHeight); rightView.layout( rightViewLeft, rightViewTop, rightViewLeft + rightViewWidth, rightViewTop + rightViewHeight); // do only once if (mMainViewTranslateOutToLeft == null) initAnim(width, leftViewWidth, rightViewWidth); doAnimation(); }
/** Override method to configure the dragged view and secondView layout properly. */ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (isInEditMode()) super.onLayout(changed, left, top, right, bottom); else if (isDragViewAtTop()) { dragView.layout(left, top, right, transformer.getOriginalHeight()); secondView.layout(left, transformer.getOriginalHeight(), right, bottom); ViewHelper.setY(dragView, top); ViewHelper.setY(secondView, transformer.getOriginalHeight()); } else { secondView.layout(left, transformer.getOriginalHeight(), right, bottom); } }
@Override protected void onLayout(boolean b, int i, int i1, int i2, int i3) { if (b) { mContentView.setClickable(true); mMenuView.setClickable(true); mMenuView.setBackgroundColor(Color.TRANSPARENT); mMenuView.layout(0, 0, mScreenWidth - mMenuOffset, mScreenHeight); mContentView.layout( mScreenWidth - mMenuOffset, 0, mScreenWidth - mMenuOffset + mScreenWidth, mScreenHeight); scrollTo(mScreenWidth - mMenuOffset, 0); } }
protected int positionChild(View child, int x, int y, int contentHeight, boolean reverse) { int childWidth = child.getMeasuredWidth(); int childHeight = child.getMeasuredHeight(); int childTop = y + (contentHeight - childHeight) / 2; if (reverse) { child.layout(x - childWidth, childTop, x, childTop + childHeight); } else { child.layout(x, childTop, x + childWidth, childTop + childHeight); } return (reverse ? -childWidth : childWidth); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); // 实现布局在动的效果 downPullView.layout( 0, pullY - downPullView.getMeasuredHeight(), downPullView.getMeasuredWidth(), pullY); pullAbleView.layout( 0, pullY, pullAbleView.getMeasuredWidth(), pullY + pullAbleView.getMeasuredHeight()); upPullView.layout( 0, pullY + getMeasuredHeight(), upPullView.getMeasuredWidth(), pullY + getMeasuredHeight() + upPullView.getMeasuredHeight()); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); if (firstView != null) { firstView.layout(0, offsetTop, firstView.getMeasuredWidth(), offsetTop + firstViewHeight); } if (secondView != null) { secondView.layout( 0, offsetTop + firstViewHeight, secondView.getMeasuredWidth(), offsetTop + firstViewHeight + secondView.getMeasuredHeight()); } }