Example usage for android.view View getMeasuredWidthAndState

List of usage examples for android.view View getMeasuredWidthAndState

Introduction

In this page you can find the example usage for android.view View getMeasuredWidthAndState.

Prototype

@ViewDebug.ExportedProperty(category = "measurement", flagMapping = {
        @ViewDebug.FlagToString(mask = MEASURED_STATE_MASK, equals = MEASURED_STATE_TOO_SMALL, name = "MEASURED_STATE_TOO_SMALL"), })
public final int getMeasuredWidthAndState() 

Source Link

Document

Return the full width measurement information for this view as computed by the most recent call to #measure(int,int) .

Usage

From source file:com.example.administrator.myapplication.recycler_swipe.swpie.SwipeMenuLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int contentViewHeight;
    if (mContentView != null) {
        int contentViewWidth = mContentView.getMeasuredWidthAndState();
        contentViewHeight = mContentView.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) mContentView.getLayoutParams();
        int start = getPaddingLeft();
        int top = getPaddingTop() + lp.topMargin;
        mContentView.layout(start, top, start + contentViewWidth, top + contentViewHeight);
    }/*from  ww  w.ja  v a 2s . c o m*/

    if (mSwipeLeftHorizontal != null) {
        View leftMenu = mSwipeLeftHorizontal.getMenuView();
        int menuViewWidth = leftMenu.getMeasuredWidthAndState();
        int menuViewHeight = leftMenu.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) leftMenu.getLayoutParams();
        int top = getPaddingTop() + lp.topMargin;
        leftMenu.layout(-menuViewWidth, top, 0, top + menuViewHeight);
    }

    if (mSwipeRightHorizontal != null) {
        View rightMenu = mSwipeRightHorizontal.getMenuView();
        int menuViewWidth = rightMenu.getMeasuredWidthAndState();
        int menuViewHeight = rightMenu.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) rightMenu.getLayoutParams();
        int top = getPaddingTop() + lp.topMargin;

        int parentViewWidth = getMeasuredWidthAndState();
        rightMenu.layout(parentViewWidth, top, parentViewWidth + menuViewWidth, top + menuViewHeight);
    }
}

From source file:com.lfq.pulltorefresh.library.sideslip.SwipeMenuLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int contentViewHeight = 0;
    if (mContentView != null) {
        int contentViewWidth = mContentView.getMeasuredWidthAndState();
        contentViewHeight = mContentView.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) mContentView.getLayoutParams();
        int start = getPaddingLeft();
        int top = getPaddingTop() + lp.topMargin;
        mContentView.layout(start, top, start + contentViewWidth, top + contentViewHeight);
    }/*from  ww w .j  av  a2  s  . c om*/

    if (mSwipeRightHorizontal != null) {
        View rightMenu = mSwipeRightHorizontal.getMenuView();
        int menuViewWidth = rightMenu.getMeasuredWidthAndState();
        //            int menuViewHeight = contentViewHeight == 0 ? rightMenu.getMeasuredHeightAndState() : contentViewHeight;
        int menuViewHeight = rightMenu.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) rightMenu.getLayoutParams();
        int top = getPaddingTop() + lp.topMargin;

        int parentViewWidth = getMeasuredWidthAndState();
        rightMenu.layout(parentViewWidth, top, parentViewWidth + menuViewWidth, top + menuViewHeight);
    }
}

From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int contentViewHeight = 0;
    if (mContentView != null) {
        int contentViewWidth = mContentView.getMeasuredWidthAndState();
        contentViewHeight = mContentView.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) mContentView.getLayoutParams();
        int start = getPaddingLeft();
        int top = getPaddingTop() + lp.topMargin;
        mContentView.layout(start, top, start + contentViewWidth, top + contentViewHeight);
    }/*w  w w .  j  av a 2  s . c o  m*/

    if (mSwipeLeftHorizontal != null) {
        View leftMenu = mSwipeLeftHorizontal.getMenuView();
        int menuViewWidth = leftMenu.getMeasuredWidthAndState();
        //            int menuViewHeight = contentViewHeight == 0 ? leftMenu.getMeasuredHeightAndState() : contentViewHeight;
        int menuViewHeight = leftMenu.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) leftMenu.getLayoutParams();
        int top = getPaddingTop() + lp.topMargin;
        leftMenu.layout(-menuViewWidth, top, 0, top + menuViewHeight);
    }

    if (mSwipeRightHorizontal != null) {
        View rightMenu = mSwipeRightHorizontal.getMenuView();
        int menuViewWidth = rightMenu.getMeasuredWidthAndState();
        //            int menuViewHeight = contentViewHeight == 0 ? rightMenu.getMeasuredHeightAndState() : contentViewHeight;
        int menuViewHeight = rightMenu.getMeasuredHeightAndState();
        LayoutParams lp = (LayoutParams) rightMenu.getLayoutParams();
        int top = getPaddingTop() + lp.topMargin;

        int parentViewWidth = getMeasuredWidthAndState();
        rightMenu.layout(parentViewWidth, top, parentViewWidth + menuViewWidth, top + menuViewHeight);
    }
}