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:com.acbelter.scheduleview.ScheduleView.java
private void positionItemViews() { if (mAdapter == null) { return;/*from w w w .jav a 2 s . c o m*/ } View child; final int right = mViewWidth - getPaddingRight() - mItemPaddingRight; for (int i = 0; i < mAdapter.getCount(); i++) { child = getChildAt(i); int width = child.getMeasuredWidth(); int height = child.getMeasuredHeight(); GeneralScheduleItem item = mAdapter.getItem(i); int top = mListY + mInternalPaddingTop + getPaddingTop() + mTimeMarkHeight / 2 + calculateDistance(mStartTime, getTimeInMillis(item.getStartTime())); child.layout(right - width, top, right, top + height); } }
From source file:com.example.adminstrator.pullrefresh.SwipeRefreshLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); int barH = height / 2 - 2; mPullMaxDistance = barH;// w w w.j ava 2 s .c o m mProgressBar.layout(0, -barH, width, 2); mProgressBarBottom.layout(0, height - 2, width, height + barH); final LayoutParams lp = mProgressBar.getLayoutParams(); if (lp.height != (barH + 2)) { lp.height = barH + 2; mProgressBar.post(new Runnable() { @Override public void run() { mProgressBar.setLayoutParams(lp); } }); } if (getChildCount() == 0) { return; } final View child = getChildAt(2); 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.example.gitnb.widget.SwipeRefreshLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); if (getChildCount() == 0) { return;// www .j av a2 s. c om } if (mTarget == null) { ensureTarget(); } if (mTarget == null) { return; } int circleWidth = mCircleView.getMeasuredWidth(); int circleHeight = mCircleView.getMeasuredHeight(); mCircleView.layout((width / 2 - circleWidth / 2), mCurrentTargetOffsetTop, (width / 2 + circleWidth / 2), mCurrentTargetOffsetTop + circleHeight); final View child = mTarget; final int childLeft = getPaddingLeft(); final int childTop = getPaddingTop(); final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, mCurrentTargetOffsetTop + circleHeight + childTop, childLeft + childWidth, mCurrentTargetOffsetTop + circleHeight + childTop + childHeight); }
From source file:android.support.v7.internal.widget.ActionBarOverlayLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int count = getChildCount(); final int parentLeft = getPaddingLeft(); final int parentRight = right - left - getPaddingRight(); final int parentTop = getPaddingTop(); final int parentBottom = bottom - top - getPaddingBottom(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int width = child.getMeasuredWidth(); final int height = child.getMeasuredHeight(); int childLeft = parentLeft + lp.leftMargin; int childTop; if (child == mActionBarBottom) { childTop = parentBottom - height - lp.bottomMargin; } else { childTop = parentTop + lp.topMargin; }//from www .j av a 2s .c o m child.layout(childLeft, childTop, childLeft + width, childTop + height); } } }
From source file:com.ylw.split.splitview.view.SplitView.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); //view//w ww. j a v a 2 s . c o m View child = getChildAt(0); int childRight = child.getMeasuredWidth(); int childBottom = child.getMeasuredHeight(); child.layout(0, 0, childRight, childBottom); //view child = getChildAt(1); mSlideOffset = 0; mSlideRange = 300; //? childRight = child.getMeasuredWidth(); childBottom = child.getMeasuredHeight(); child.layout(50, 0, childRight, childBottom); mFirstLayout = false; }
From source file:com.jinzht.pro.swipyrefreshlayout.SwipyRefreshLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); if (getChildCount() == 0) { return;//from w w w. j av a 2 s . c om } if (mTarget == null) { ensureTarget(); } if (mTarget == null) { return; } // final View child = mTarget;// ? View child = mTarget;// 2016.03.24 final int childLeft = getPaddingLeft(); final int childTop = getPaddingTop(); final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); int circleWidth = mCircleView.getMeasuredWidth(); int circleHeight = mCircleView.getMeasuredHeight(); mCircleView.layout((width / 2 - circleWidth / 2), mCurrentTargetOffsetTop, (width / 2 + circleWidth / 2), mCurrentTargetOffsetTop + circleHeight); }
From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int width = getWidth(); int ypos = mTopOffset; int leftEdge = getPaddingLeft(); int rightEdge = width - getPaddingRight(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (child.getVisibility() == GONE) { continue; }//from w w w .j av a 2s. co m int top = ypos + lp.topMargin; if (lp.ignoreOffset) { top -= mCollapseOffset; } final int bottom = top + child.getMeasuredHeight(); final int childWidth = child.getMeasuredWidth(); final int widthAvailable = rightEdge - leftEdge; final int left = leftEdge + (widthAvailable - childWidth) / 2; final int right = left + childWidth; child.layout(left, top, right, bottom); ypos = bottom + lp.bottomMargin; } mIsLaidOut = true; }
From source file:com.aizou.core.widget.pagerIndicator.indicator.FixedIndicatorView.java
private void measureScrollBar(boolean needChange) { if (scrollBar == null) return;//from w ww. ja v a 2 s .com View view = scrollBar.getSlideView(); if (view.isLayoutRequested() || needChange) { if (mAdapter != null && mAdapter.getCount() > 0 && mSelectedTabIndex >= 0 && mSelectedTabIndex < mAdapter.getCount()) { int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), mWidthMode); int heightSpec; ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams != null && layoutParams.height > 0) { heightSpec = MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY); } else { heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } view.measure(widthSpec, heightSpec); View curr = getChildAt(mSelectedTabIndex); view.layout(0, 0, scrollBar.getWidth(curr.getMeasuredWidth()), scrollBar.getHeight(getHeight())); } } }
From source file:com.grottworkshop.gwsmaterialcalendarview.MaterialCalendarView.java
/** * {@inheritDoc}/*from ww w .j a v a 2 s.com*/ */ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int count = getChildCount(); final int parentLeft = getPaddingLeft(); final int parentWidth = right - left - parentLeft - getPaddingRight(); int childTop = getPaddingTop(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == View.GONE) { continue; } final int width = child.getMeasuredWidth(); final int height = child.getMeasuredHeight(); int delta = (parentWidth - width) / 2; int childLeft = parentLeft + delta; child.layout(childLeft, childTop, childLeft + width, childTop + height); childTop += height; } }
From source file:com.sno.customintegration.customswiperefreshlayout.view.CustomSwipeRefreshLayout.java
/** * ?/*from w w w . j a va 2s .c om*/ * * @param changed * @param left * @param top * @param right * @param bottom */ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); if (getChildCount() == 0) { return; } if (mTarget == null) { ensureTarget(); } if (mTarget == null) { return; } final View child = mTarget; final int childLeft = getPaddingLeft(); final int childTop = getPaddingTop(); final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); int circleWidth = mCircleView.getMeasuredWidth(); int circleHeight = mCircleView.getMeasuredHeight(); // mCircleView.layout((width / 2 - circleWidth / 2), mCurrentTargetOffsetTop, // (width / 2 + circleWidth / 2), mCurrentTargetOffsetTop + circleHeight); // TODO mCircleView.layout(childLeft, mCurrentTargetOffsetTop, (childLeft + circleWidth), mCurrentTargetOffsetTop + circleHeight); }