Java Code Examples for android.view.View.getMeasuredWidth()

The following are Jave code examples for showing how to use getMeasuredWidth() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: CXJPadProject   File: FullyLinearLayoutManager.java   Source Code and License Vote up 6 votes
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
                               int heightSpec, int[] measuredDimension) {
    try {
        View view = recycler.getViewForPosition(0);//fix 动态添加时报IndexOutOfBoundsException

        if (view != null) {
            RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();

            int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
                    getPaddingLeft() + getPaddingRight(), p.width);

            int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
                    getPaddingTop() + getPaddingBottom(), p.height);

            view.measure(childWidthSpec, childHeightSpec);
            measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
            measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
            recycler.recycleView(view);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
    }
}
 
Example 2
Project: TableRecyclerView   File: SingleLineLinearLayout.java   Source Code and License Vote up 6 votes
@Override
    protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) {
        // 父View 不能限制我们。模式是UNSPECIFIED  宽度所有子View宽总和, 高度取子View最大
        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
        int heightSize = MeasureSpec.getSize(heightMeasureSpec);

        int width = 0;
        int height = 0;

//        Log.i("feng",
//              "single 调用 onMeasure - widthMode :" + widthMode + " width size:  " + widthSize + " height size " + heightSize);

        for (int i = 0; i < getChildCount(); i++) {
            View childView = getChildAt(i);

            int widthChild = MeasureSpec.makeMeasureSpec(widthSize,MeasureSpec.UNSPECIFIED);
            int heightChild = MeasureSpec.makeMeasureSpec(heightSize,MeasureSpec.UNSPECIFIED);

            childView.measure(widthChild,heightChild);

            width += childView.getMeasuredWidth();
            height = Math.max(height,childView.getMeasuredHeight());
        }
        setMeasuredDimension(width,height);
    }
 
Example 3
Project: cniao5   File: FullyLinearLayoutManager.java   Source Code and License Vote up 6 votes
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
                               int heightSpec, int[] measuredDimension) {
    try {
        View view = recycler.getViewForPosition(position);//fix 动态添加时报IndexOutOfBoundsException

        if (view != null) {
            RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();

            int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
                    getPaddingLeft() + getPaddingRight(), p.width);

            int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
                    getPaddingTop() + getPaddingBottom(), p.height);

            view.measure(childWidthSpec, childHeightSpec);
            measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
            measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
            recycler.recycleView(view);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 4
Project: android-BlankSpace   File: BlankSpacePopup.java   Source Code and License Vote up 5 votes
public void show(View anchor) {
    if(!isShowing()) {
        this.blankWindow = new PopupWindow(this.blankView, anchor.getMeasuredWidth(), anchor.getMeasuredHeight());
        this.blankWindow.setAnimationStyle(this.animation);
        if(this.animationStyle != -1) this.blankWindow.setAnimationStyle(animationStyle);
        this.blankWindow.showAtLocation(anchor, Gravity.CENTER, 0, anchor.getHeight());
        this.isShowing = true;
    }
}
 
Example 5
Project: OSchina_resources_android   File: ScrollLayout.java   Source Code and License Vote up 5 votes
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int childLeft = 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View childView = getChildAt(i);
        if (childView.getVisibility() != View.GONE) {
            final int childWidth = childView.getMeasuredWidth();
            childView.layout(childLeft, 0, childLeft + childWidth,
                    childView.getMeasuredHeight());
            childLeft += childWidth;
        }
    }
}
 
Example 6
Project: Andzu   File: BubblesLayoutCoordinator.java   Source Code and License Vote up 5 votes
private void applyTrashMagnetismToBubble(BubbleLayout bubble) {
    View trashContentView = getTrashContent();
    int trashCenterX = (trashContentView.getLeft() + (trashContentView.getMeasuredWidth() / 2));
    int trashCenterY = (trashContentView.getTop() + (trashContentView.getMeasuredHeight() / 2));
    int x = (trashCenterX - (bubble.getMeasuredWidth() / 2));
    int y = (trashCenterY - (bubble.getMeasuredHeight() / 2));
    bubble.getViewParams().x = x;
    bubble.getViewParams().y = y;
    windowManager.updateViewLayout(bubble, bubble.getViewParams());
}
 
Example 7
Project: BlogBookApp   File: OrientationStateVertical.java   Source Code and License Vote up 5 votes
@Override
public void initPlaceHolderAndOverlay(@Nullable View overlayPlaceHolder, View rvContainer,
                                      View selectorContainer, int overlaySize) {
    if (overlayPlaceHolder != null) {
        int containerWidth = rvContainer.getMeasuredWidth();

        //make placeholder same height as a recyclerView
        overlayPlaceHolder.getLayoutParams().width = containerWidth;
        overlayPlaceHolder.requestLayout();

        selectorContainer.getLayoutParams().width = containerWidth + overlaySize;
        selectorContainer.requestLayout();

    }
}
 
Example 8
Project: boohee_v5.6   File: AbsActionBarView.java   Source Code and License Vote up 5 votes
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;
}
 
Example 9
Project: PSNine   File: TopicActivity.java   Source Code and License Vote up 5 votes
private void showHideWithAnimation(final View view, boolean show, boolean center) {
    int cx = view.getMeasuredWidth();
    int cy = view.getMeasuredHeight();
    int w = view.getWidth();
    int h = view.getHeight();
    float r = (float) Math.sqrt(w * w + h * h);
    if (center) {
        cx = cx / 2;
        cy = cy / 2;
        r = Math.max(w / 2, h / 2);
    }
    Animator anim;
    if (show) {
        anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, r);
        view.setVisibility(View.VISIBLE);
    } else {
        anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, r, 0);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                view.setVisibility(View.INVISIBLE);
            }
        });
    }
    anim.start();
}
 
Example 10
Project: mupdf-android-viewer-nui   File: ProofActivity.java   Source Code and License Vote up 5 votes
private static int getWidestView(Context context, Adapter adapter)
{
	int maxWidth = 0;
	View view = null;
	FrameLayout fakeParent = new FrameLayout(context);
	for (int i=0, count=adapter.getCount(); i<count; i++) {
		view = adapter.getView(i, view, fakeParent);
		view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
		int width = view.getMeasuredWidth();
		if (width > maxWidth) {
			maxWidth = width;
		}
	}
	return maxWidth;
}
 
Example 11
Project: sealtalk-android-master   File: HorizontalListView.java   Source Code and License Vote up 5 votes
private void removeNonVisibleChildren(final int dx) {
    View child = getLeftmostChild();

    // Loop removing the leftmost child, until that child is on the screen
    while (child != null && child.getRight() + dx <= 0) {
        // The child is being completely removed so remove its width from the display offset and its divider if it has one.
        // To remove add the size of the child and its divider (if it has one) to the offset.
        // You need to add since its being removed from the left side, i.e. shifting the offset to the right.
        mDisplayOffset += isLastItemInAdapter(mLeftViewAdapterIndex) ? child.getMeasuredWidth() : mDividerWidth + child.getMeasuredWidth();

        // Add the removed view to the cache
        recycleView(mLeftViewAdapterIndex, child);

        // Actually remove the view
        removeViewInLayout(child);

        // Keep track of the adapter index of the left most child
        mLeftViewAdapterIndex++;

        // Get the new leftmost child
        child = getLeftmostChild();
    }

    child = getRightmostChild();

    // Loop removing the rightmost child, until that child is on the screen
    while (child != null && child.getLeft() + dx >= getWidth()) {
        recycleView(mRightViewAdapterIndex, child);
        removeViewInLayout(child);
        mRightViewAdapterIndex--;
        child = getRightmostChild();
    }
}
 
Example 12
Project: SearchLayout   File: FlowLayout.java   Source Code and License Vote up 4 votes
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
    int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
    int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
    int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
    int modeHeight = MeasureSpec.getMode(heightMeasureSpec);

    // wrap_content
    int width = 0;
    int height = 0;

    int lineWidth = 0;
    int lineHeight = 0;

    int cCount = getChildCount();

    for (int i = 0; i < cCount; i++)
    {
        View child = getChildAt(i);
        if (child.getVisibility() == View.GONE)
        {
            if (i == cCount - 1)
            {
                width = Math.max(lineWidth, width);
                height += lineHeight;
            }
            continue;
        }
        measureChild(child, widthMeasureSpec, heightMeasureSpec);
        MarginLayoutParams lp = (MarginLayoutParams) child
                .getLayoutParams();

        int childWidth = child.getMeasuredWidth() + lp.leftMargin
                + lp.rightMargin;
        int childHeight = child.getMeasuredHeight() + lp.topMargin
                + lp.bottomMargin;

        if (lineWidth + childWidth > sizeWidth - getPaddingLeft() - getPaddingRight())
        {
            width = Math.max(width, lineWidth);
            lineWidth = childWidth;
            height += lineHeight;
            lineHeight = childHeight;
        } else
        {
            lineWidth += childWidth;
            lineHeight = Math.max(lineHeight, childHeight);
        }
        if (i == cCount - 1)
        {
            width = Math.max(lineWidth, width);
            height += lineHeight;
        }
    }
    setMeasuredDimension(
            //
            modeWidth == MeasureSpec.EXACTLY ? sizeWidth : width + getPaddingLeft() + getPaddingRight(),
            modeHeight == MeasureSpec.EXACTLY ? sizeHeight : height + getPaddingTop() + getPaddingBottom()//
    );

}
 
Example 13
Project: letv   File: UIsUtils.java   Source Code and License Vote up 4 votes
public static int[] measureSize(View v) {
    v.measure(MeasureSpec.makeMeasureSpec(0, 0), MeasureSpec.makeMeasureSpec(0, 0));
    int width = v.getMeasuredWidth();
    int height = v.getMeasuredHeight();
    return new int[]{width, height};
}
 
Example 14
Project: Swap   File: PLA_ListView.java   Source Code and License Vote up 4 votes
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // Sets up mListPadding
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    int childWidth = 0;
    int childHeight = 0;

    mItemCount = mAdapter == null ? 0 : mAdapter.getCount();
    if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED ||
            heightMode == MeasureSpec.UNSPECIFIED)) {
        final View child = obtainView(0, mIsScrap);

        measureScrapChild(child, 0, widthMeasureSpec);

        childWidth = child.getMeasuredWidth();
        childHeight = child.getMeasuredHeight();

        if (recycleOnMeasure() && mRecycler.shouldRecycleViewType(
                ((LayoutParams) child.getLayoutParams()).viewType)) {
            mRecycler.addScrapView(child);
        }
    }

    if (widthMode == MeasureSpec.UNSPECIFIED) {
        widthSize = mListPadding.left + mListPadding.right + childWidth +
                getVerticalScrollbarWidth();
    }

    if (heightMode == MeasureSpec.UNSPECIFIED) {
        heightSize = mListPadding.top + mListPadding.bottom + childHeight +
                getVerticalFadingEdgeLength() * 2;
    }

    if (heightMode == MeasureSpec.AT_MOST) {
        // TODO: after first layout we should maybe start at the first visible position, not 0
        heightSize = measureHeightOfChildren(widthMeasureSpec, 0, NO_POSITION, heightSize, -1);
    }

    setMeasuredDimension(widthSize, heightSize);
    mWidthMeasureSpec = widthMeasureSpec;
}
 
Example 15
Project: boohee_v5.6   File: LinearLayoutCompat.java   Source Code and License Vote up 4 votes
void layoutVertical(int left, int top, int right, int bottom) {
    int childTop;
    int paddingLeft = getPaddingLeft();
    int width = right - left;
    int childRight = width - getPaddingRight();
    int childSpace = (width - paddingLeft) - getPaddingRight();
    int count = getVirtualChildCount();
    int minorGravity = this.mGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK;
    switch (this.mGravity & 112) {
        case 16:
            childTop = getPaddingTop() + (((bottom - top) - this.mTotalLength) / 2);
            break;
        case 80:
            childTop = ((getPaddingTop() + bottom) - top) - this.mTotalLength;
            break;
        default:
            childTop = getPaddingTop();
            break;
    }
    int i = 0;
    while (i < count) {
        View child = getVirtualChildAt(i);
        if (child == null) {
            childTop += measureNullChild(i);
        } else if (child.getVisibility() != 8) {
            int childLeft;
            int childWidth = child.getMeasuredWidth();
            int childHeight = child.getMeasuredHeight();
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            int gravity = lp.gravity;
            if (gravity < 0) {
                gravity = minorGravity;
            }
            switch (GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)) & 7) {
                case 1:
                    childLeft = ((((childSpace - childWidth) / 2) + paddingLeft) + lp.leftMargin) - lp.rightMargin;
                    break;
                case 5:
                    childLeft = (childRight - childWidth) - lp.rightMargin;
                    break;
                default:
                    childLeft = paddingLeft + lp.leftMargin;
                    break;
            }
            if (hasDividerBeforeChildAt(i)) {
                childTop += this.mDividerHeight;
            }
            childTop += lp.topMargin;
            setChildFrame(child, childLeft, childTop + getLocationOffset(child), childWidth, childHeight);
            childTop += (lp.bottomMargin + childHeight) + getNextLocationOffset(child);
            i += getChildrenSkipCount(child, i);
        }
        i++;
    }
}
 
Example 16
Project: ImageClassify   File: ShareUtil.java   Source Code and License Vote up 4 votes
/**
 * 分享排行榜截图
 *
 * @param context
 * @param listView
 * @param handler
 */
public static void shareRankShot(final Context context, final ListView listView, final Handler handler) {
    if (context != null && listView != null) {
        CommonAdapter adapter = (CommonAdapter) listView.getAdapter();
        int itemsCount = adapter.getCount();
        int allItemsHeight = 0;
        int itemWidth = 0;
        final List<Bitmap> bitmapList = new ArrayList<Bitmap>();

        //获取ListView的Bitmap集合
        for (int i = 0; i < itemsCount; i++) {
            View childView = adapter.getView(i, null, listView);
            Drawable defaultDrawable = context.getResources().getDrawable(R.mipmap.ic_launcher);
            childView.measure(MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
            itemWidth = childView.getMeasuredWidth();
            childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
            childView.setDrawingCacheEnabled(true);
            childView.buildDrawingCache();
            bitmapList.add(childView.getDrawingCache());
            allItemsHeight += childView.getMeasuredHeight();
        }

        final int finalItemWidth = itemWidth;
        final int finalAllItemsHeight = allItemsHeight;
        //开启子线程合并图片并分享
        new Thread(new Runnable() {
            @Override
            public void run() {
                Bitmap bigBitmap = Bitmap.createBitmap(finalItemWidth, finalAllItemsHeight, Bitmap.Config.ARGB_8888);
                Canvas bigCanvas = new Canvas(bigBitmap);
                Paint paint = new Paint();
                int iHeight = 0;

                for (int i = 0; i < bitmapList.size(); i++) {
                    Bitmap bmp = bitmapList.get(i);
                    bigCanvas.drawBitmap(bmp, 0, iHeight, paint);
                    iHeight += bmp.getHeight();
                    bmp.recycle();
                    bmp = null;
                }

                String screenShotPathName = "";
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);

                if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                    //以当前时间作为图片前缀
                    final String screenShotName = Environment.getExternalStorageDirectory().getPath()
                            + File.separator
                            + simpleDateFormat.format(new Date())
                            + "screenshot.png";
                    try {
                        FileOutputStream out = new FileOutputStream(screenShotName);
                        boolean isSaved = bigBitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
                        if (isSaved) {
                            handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    share(context, SHARE_TYPE.SHARE_IMAGE, "我的排名",
                                            "分享排名", screenShotName);
                                }
                            });
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

    }
}
 
Example 17
Project: photo-editor-android   File: SlidingUpPanelLayout.java   Source Code and License Vote up 4 votes
@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;
                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;
}
 
Example 18
Project: mupdf-android-viewer-old   File: ReaderView.java   Source Code and License Vote up 4 votes
public void smartMoveForwards() {
	View v = mChildViews.get(mCurrent);
	if (v == null)
		return;

	// The following code works in terms of where the screen is on the views;
	// so for example, if the currentView is at (-100,-100), the visible
	// region would be at (100,100). If the previous page was (2000, 3000) in
	// size, the visible region of the previous page might be (2100 + GAP, 100)
	// (i.e. off the previous page). This is different to the way the rest of
	// the code in this file is written, but it's easier for me to think about.
	// At some point we may refactor this to fit better with the rest of the
	// code.

	// screenWidth/Height are the actual width/height of the screen. e.g. 480/800
	int screenWidth = getWidth();
	int screenHeight = getHeight();
	// We might be mid scroll; we want to calculate where we scroll to based on
	// where this scroll would end, not where we are now (to allow for people
	// bashing 'forwards' very fast.
	int remainingX = mScroller.getFinalX() - mScroller.getCurrX();
	int remainingY = mScroller.getFinalY() - mScroller.getCurrY();
	// right/bottom is in terms of pixels within the scaled document; e.g. 1000
	int top = -(v.getTop() + mYScroll + remainingY);
	int right = screenWidth -(v.getLeft() + mXScroll + remainingX);
	int bottom = screenHeight+top;
	// docWidth/Height are the width/height of the scaled document e.g. 2000x3000
	int docWidth = v.getMeasuredWidth();
	int docHeight = v.getMeasuredHeight();

	int xOffset, yOffset;
	if (bottom >= docHeight) {
		// We are flush with the bottom. Advance to next column.
		if (right + screenWidth > docWidth) {
			// No room for another column - go to next page
			View nv = mChildViews.get(mCurrent+1);
			if (nv == null) // No page to advance to
				return;
			int nextTop = -(nv.getTop() + mYScroll + remainingY);
			int nextLeft = -(nv.getLeft() + mXScroll + remainingX);
			int nextDocWidth = nv.getMeasuredWidth();
			int nextDocHeight = nv.getMeasuredHeight();

			// Allow for the next page maybe being shorter than the screen is high
			yOffset = (nextDocHeight < screenHeight ? ((nextDocHeight - screenHeight)>>1) : 0);

			if (nextDocWidth < screenWidth) {
				// Next page is too narrow to fill the screen. Scroll to the top, centred.
				xOffset = (nextDocWidth - screenWidth)>>1;
			} else {
				// Reset X back to the left hand column
				xOffset = right % screenWidth;
				// Adjust in case the previous page is less wide
				if (xOffset + screenWidth > nextDocWidth)
					xOffset = nextDocWidth - screenWidth;
			}
			xOffset -= nextLeft;
			yOffset -= nextTop;
		} else {
			// Move to top of next column
			xOffset = screenWidth;
			yOffset = screenHeight - bottom;
		}
	} else {
		// Advance by 90% of the screen height downwards (in case lines are partially cut off)
		xOffset = 0;
		yOffset = smartAdvanceAmount(screenHeight, docHeight - bottom);
	}
	mScrollerLastX = mScrollerLastY = 0;
	mScroller.startScroll(0, 0, remainingX - xOffset, remainingY - yOffset, 400);
	mStepper.prod();
}
 
Example 19
Project: PlusGram   File: FrameLayoutFixed.java   Source Code and License Vote up 4 votes
public final int getMeasuredStateFixed(View view) {
    return (view.getMeasuredWidth()&0xff000000)
            | ((view.getMeasuredHeight()>>16)
            & (0xff000000>>16));
}
 
Example 20
Project: airgram   File: RecyclerView.java   Source Code and License Vote up 2 votes
/**
 * Returns the measured width of the given child, plus the additional size of
 * any insets applied by {@link ItemDecoration ItemDecorations}.
 *
 * @param child Child view to query
 * @return child's measured width plus <code>ItemDecoration</code> insets
 *
 * @see View#getMeasuredWidth()
 */
public int getDecoratedMeasuredWidth(View child) {
    final Rect insets = ((LayoutParams) child.getLayoutParams()).mDecorInsets;
    return child.getMeasuredWidth() + insets.left + insets.right;
}