Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

In this page you can find the example usage for android.view Gravity LEFT.

Prototype

int LEFT

To view the source code for android.view Gravity LEFT.

Click Source Link

Document

Push object to the left of its container, not changing its size.

Usage

From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java

@Override
public void onExpand(boolean expanded) {
    if (null == mActionFabDrawable) {
        return;//  ww  w .ja  va 2  s .com
    }

    if (expanded) {
        setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
        setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
        mActionFabDrawable.setDelete(ANIMATE_TIME);
    } else {
        setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
        setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
        mActionFabDrawable.setAdd(ANIMATE_TIME);
    }
}

From source file:com.dk.view.FolderDrawerLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mInLayout = true;//from  w  w w. jav  a2s . c o m
    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();

        if (isContentView(child)) {
            child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(),
                    lp.topMargin + child.getMeasuredHeight());
        } else { // Drawer, if it wasn't onMeasure would have thrown an
                 // exception.
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();
            int childLeft;

            final float newOffset;
            if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) {
                childLeft = -childWidth + (int) (childWidth * lp.onScreen);
                newOffset = (float) (childWidth + childLeft) / childWidth;
            } else { // Right; onMeasure checked for us.
                childLeft = width - (int) (childWidth * lp.onScreen);
                newOffset = (float) (width - childLeft) / childWidth;
            }

            final boolean changeOffset = newOffset != lp.onScreen;

            final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;

            switch (vgrav) {
            default:
            case Gravity.TOP: {
                child.layout(childLeft, lp.topMargin, childLeft + childWidth, lp.topMargin + childHeight);
                break;
            }

            case Gravity.BOTTOM: {
                final int height = b - t;
                child.layout(childLeft, height - lp.bottomMargin - child.getMeasuredHeight(),
                        childLeft + childWidth, height - lp.bottomMargin);
                break;
            }

            case Gravity.CENTER_VERTICAL: {
                final int height = b - t;
                int childTop = (height - childHeight) / 2;

                // Offset for margins. If things don't fit right because of
                // bad measurement before, oh well.
                if (childTop < lp.topMargin) {
                    childTop = lp.topMargin;
                } else if (childTop + childHeight > height - lp.bottomMargin) {
                    childTop = height - lp.bottomMargin - childHeight;
                }
                child.layout(childLeft, childTop, childLeft + childWidth, childTop + 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:android.support.design.widget.CoordinatorLayout.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    prepareChildren();/*from   w  ww  .  j av  a  2  s  . co m*/
    ensurePreDrawListener();

    final int paddingLeft = getPaddingLeft();
    final int paddingTop = getPaddingTop();
    final int paddingRight = getPaddingRight();
    final int paddingBottom = getPaddingBottom();
    final int layoutDirection = ViewCompat.getLayoutDirection(this);
    final boolean isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    final int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    final int widthPadding = paddingLeft + paddingRight;
    final int heightPadding = paddingTop + paddingBottom;
    int widthUsed = getSuggestedMinimumWidth();
    int heightUsed = getSuggestedMinimumHeight();
    int childState = 0;

    final boolean applyInsets = mLastInsets != null && ViewCompat.getFitsSystemWindows(this);

    final int childCount = mDependencySortedChildren.size();
    for (int i = 0; i < childCount; i++) {
        final View child = mDependencySortedChildren.get(i);
        if (child.getVisibility() == GONE) {
            // If the child is GONE, skip...
            continue;
        }

        final LayoutParams lp = (LayoutParams) child.getLayoutParams();

        int keylineWidthUsed = 0;
        if (lp.keyline >= 0 && widthMode != MeasureSpec.UNSPECIFIED) {
            final int keylinePos = getKeyline(lp.keyline);
            final int keylineGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(lp.gravity),
                    layoutDirection) & Gravity.HORIZONTAL_GRAVITY_MASK;
            if ((keylineGravity == Gravity.LEFT && !isRtl) || (keylineGravity == Gravity.RIGHT && isRtl)) {
                keylineWidthUsed = Math.max(0, widthSize - paddingRight - keylinePos);
            } else if ((keylineGravity == Gravity.RIGHT && !isRtl)
                    || (keylineGravity == Gravity.LEFT && isRtl)) {
                keylineWidthUsed = Math.max(0, keylinePos - paddingLeft);
            }
        }

        int childWidthMeasureSpec = widthMeasureSpec;
        int childHeightMeasureSpec = heightMeasureSpec;
        if (applyInsets && !ViewCompat.getFitsSystemWindows(child)) {
            // We're set to handle insets but this child isn't, so we will measure the
            // child as if there are no insets
            final int horizInsets = mLastInsets.getSystemWindowInsetLeft()
                    + mLastInsets.getSystemWindowInsetRight();
            final int vertInsets = mLastInsets.getSystemWindowInsetTop()
                    + mLastInsets.getSystemWindowInsetBottom();

            childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize - horizInsets, widthMode);
            childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize - vertInsets, heightMode);
        }

        final Behavior b = lp.getBehavior();
        if (b == null || !b.onMeasureChild(this, child, childWidthMeasureSpec, keylineWidthUsed,
                childHeightMeasureSpec, 0)) {
            onMeasureChild(child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0);
        }

        widthUsed = Math.max(widthUsed,
                widthPadding + child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);

        heightUsed = Math.max(heightUsed,
                heightPadding + child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
        childState = ViewCompat.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child));
    }

    final int width = ViewCompat.resolveSizeAndState(widthUsed, widthMeasureSpec,
            childState & ViewCompat.MEASURED_STATE_MASK);
    final int height = ViewCompat.resolveSizeAndState(heightUsed, heightMeasureSpec,
            childState << ViewCompat.MEASURED_HEIGHT_STATE_SHIFT);
    setMeasuredDimension(width, height);
}

From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mInLayout = true;/* w w w .ja va 2  s.co  m*/
    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 { // Drawer, if it wasn't onMeasure would have thrown an
                 // exception.
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();
            int childTop;

            final float newOffset;
            if (checkDrawerViewAbsoluteGravity(child, Gravity.TOP)) {
                childTop = -childHeight + (int) (childHeight * lp.onScreen);
                newOffset = (float) (childHeight + childTop) / childHeight;
            } else { // Right; onMeasure checked for us.
                childTop = height - (int) (childHeight * lp.onScreen);
                newOffset = (float) (height - childTop) / childHeight;
            }

            final boolean changeOffset = newOffset != lp.onScreen;

            final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;

            switch (vgrav) {
            default:
            case Gravity.LEFT: {
                child.layout(lp.leftMargin, childTop, lp.leftMargin + childWidth, childTop + childHeight);
                break;
            }

            case Gravity.RIGHT: {
                final int width = r - l;
                child.layout(width - lp.rightMargin - childWidth, childTop, width - lp.rightMargin,
                        childTop + childHeight);
                break;
            }

            case Gravity.CENTER_HORIZONTAL: {
                final int width = r - l;
                int childLeft = (width - childWidth) / 2;

                // Offset for margins. If things don't fit right because of
                // bad measurement before, oh well.
                if (childLeft < lp.leftMargin) {
                    childLeft = lp.leftMargin;
                } else if (childLeft + childWidth > width - lp.rightMargin) {
                    childLeft = width - lp.rightMargin - childWidth;
                }
                child.layout(childLeft, childTop, childLeft + childWidth, childTop + 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.cybrosys.scientific.EventListener.java

@SuppressWarnings("deprecation")
public void showHistory() {
    shPref = ScientificActivity.ctx.getSharedPreferences("myHistpref", 0);
    int inSize = shPref.getInt("HistIndex", 0);
    System.out.println("" + inSize);
    String[] str = new String[inSize];
    for (int inI = 0; inI < inSize; inI++) {
        str[inI] = shPref.getString("hist" + inI, "");
        System.out.println(str[inI]);
    }/*w  w  w .  j a v a2 s  . c  o m*/
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    vwLayout = inflater.inflate(R.layout.pop_history,
            (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element));

    popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true);
    popmW1.setBackgroundDrawable(new BitmapDrawable());
    popmW1.setOutsideTouchable(true);
    popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0);
    tblltTable = (TableLayout) vwLayout.findViewById(R.id.tablelay);
    ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain);
    btnCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            popmW1.dismiss();

        }
    });
    txtvHistory = new TextView[inSize];
    btnHistory = new Button[inSize];
    tblrRowL = new TableRow[inSize];
    TableRow.LayoutParams buttonParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT, 1f);
    TableRow.LayoutParams textParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT, .1f);
    int inJ = 0, inL = inSize - 1;
    for (int inI = 0; inI < inSize; inI++) {
        if (!str[inI].equalsIgnoreCase("")) {
            btnHistory[inJ] = new Button(ctx);
            txtvHistory[inJ] = new TextView(ctx);
            txtvHistory[inJ].setText("" + (inJ + 1));
            txtvHistory[inJ].setGravity(Gravity.CENTER);
            txtvHistory[inJ].setTextColor(ScientificActivity.ctx.getResources().getColor(R.color.HistColor));
            txtvHistory[inJ].setLayoutParams(textParams);
            btnHistory[inJ].setText(str[inL]);
            btnHistory[inJ].setTextColor(Color.WHITE);
            btnHistory[inJ].setGravity(Gravity.LEFT);
            btnHistory[inJ].setLayoutParams(buttonParams);
            btnHistory[inJ].setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.button_effect));
            tblrRowL[inJ] = new TableRow(ctx);
            tblrRowL[inJ].addView(txtvHistory[inJ]);
            tblrRowL[inJ].addView(btnHistory[inJ]);
            tblltTable.addView(tblrRowL[inJ]);
            final int inK = inJ;
            btnHistory[inK].setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    // etxt.setText(btns[inK].getText().toString());
                    mHandler.insert(btnHistory[inK].getText().toString());
                    popmW1.dismiss();
                }
            });

            inJ++;
            inL--;
        }

    }
    if (inSize == 0) {
        TextView txtvHistory = new TextView(ctx);
        txtvHistory.setLayoutParams(textParams);
        txtvHistory.setGravity(Gravity.CENTER);
        txtvHistory.setTextColor(Color.WHITE);
        txtvHistory.setText("History Empty");
        TableRow tblrRowL = new TableRow(ctx);
        tblrRowL.addView(txtvHistory);
        tblltTable.addView(tblrRowL);
    }
}

From source file:com.doubleTwist.drawerlib.ADrawerLayout.java

private void readViews() {
    mContent = getChildAt(0);// w  w w.  j  a  va2 s.  co  m
    for (int i = 1, count = getChildCount(); i < count; i++) {
        View v = getChildAt(i);
        if (v.getId() == DIMMER_VIEW_ID)
            continue;
        LayoutParams params = (LayoutParams) v.getLayoutParams();
        switch (params.gravity) {
        case Gravity.LEFT: // left
            mLeft = v;
            mDrawerState.mLeftEnabled = true;
            break;
        case Gravity.RIGHT: // right
            mRight = v;
            mDrawerState.mRightEnabled = true;
            break;
        case Gravity.TOP: // top
            mTop = v;
            mDrawerState.mTopEnabled = true;
            break;
        case Gravity.BOTTOM: // bottom
            mBottom = v;
            mDrawerState.mBottomEnabled = true;
            break;
        default:
            mLeft = v;
            break;
        }
    }
}

From source file:com.example.emachine.FXcalcActivity.java

private void ProgrammaticFAB() {
    if (getPrefBugIssue(getBaseContext()))
        Crashlytics.log(Log.ERROR, TAG, "ProgrammaticFAB ...");
    FloatingActionButton btn_pFAB = new FloatingActionButton.Builder(this)
            .withDrawable(getResources().getDrawable(R.drawable.idea)).withButtonColor(Color.BLUE)
            .withGravity(Gravity.BOTTOM | Gravity.LEFT).withMargins(0, 0, 16, 16).create();
    btn_pFAB.setOnClickListener(new View.OnClickListener() {

        @Override/*from www  . ja va 2s  .  c o  m*/
        public void onClick(View v) {
            Snackbar.make(v, "Programmatic FAB selected.", Snackbar.LENGTH_LONG).setAction("Action", null)
                    .show();

        }
    });

}

From source file:com.aidy.bottomdrawerlayout.DrawerLayout.java

@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    Log.i(TAG, "drawChild()");
    final int height = getHeight();
    final boolean drawingContent = isContentView(child);
    int clipLeft = 0, clipRight = getWidth();

    final int restoreCount = canvas.save();
    if (drawingContent) {
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View v = getChildAt(i);
            if (v == child || v.getVisibility() != VISIBLE || !hasOpaqueBackground(v) || !isDrawerView(v)
                    || v.getHeight() < height) {
                Log.i(TAG, "drawChild() -- 0");
                continue;
            }/*from  w  w  w.  ja  va  2 s.  com*/

            if (checkDrawerViewAbsoluteGravity(v, Gravity.LEFT)) {
                Log.i(TAG, "drawChild() -- 1");
                final int vright = v.getRight();
                if (vright > clipLeft)
                    clipLeft = vright;
            } else {
                Log.i(TAG, "drawChild() -- 2");
                final int vleft = v.getLeft();
                if (vleft < clipRight)
                    clipRight = vleft;
            }
        }
        canvas.clipRect(clipLeft, 0, clipRight, getHeight());
    }
    final boolean result = super.drawChild(canvas, child, drawingTime);
    canvas.restoreToCount(restoreCount);

    if (mScrimOpacity > 0 && drawingContent) {
        Log.i(TAG, "drawChild() -- drawingContent");
        final int baseAlpha = (mScrimColor & 0xff000000) >>> 24;
        final int imag = (int) (baseAlpha * mScrimOpacity);
        final int color = imag << 24 | (mScrimColor & 0xffffff);
        mScrimPaint.setColor(color);

        canvas.drawRect(clipLeft, 0, clipRight, getHeight(), mScrimPaint);
    } else if (mShadowLeft != null && checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) {
        Log.i(TAG, "drawChild() -- Gravity.LEFT");
        final int shadowWidth = mShadowLeft.getIntrinsicWidth();
        final int childRight = child.getRight();
        final int drawerPeekDistance = mLeftDragger.getEdgeSize();
        final float alpha = Math.max(0, Math.min((float) childRight / drawerPeekDistance, 1.f));
        mShadowLeft.setBounds(childRight, child.getTop(), childRight + shadowWidth, child.getBottom());
        mShadowLeft.setAlpha((int) (0xff * alpha));
        mShadowLeft.draw(canvas);
    } else if (mShadowRight != null && checkDrawerViewAbsoluteGravity(child, Gravity.RIGHT)) {
        Log.i(TAG, "drawChild() -- Gravity.RIGHT");
        final int shadowWidth = mShadowRight.getIntrinsicWidth();
        final int childLeft = child.getLeft();
        final int showing = getWidth() - childLeft;
        final int drawerPeekDistance = mRightDragger.getEdgeSize();
        final float alpha = Math.max(0, Math.min((float) showing / drawerPeekDistance, 1.f));
        mShadowRight.setBounds(childLeft - shadowWidth, child.getTop(), childLeft, child.getBottom());
        mShadowRight.setAlpha((int) (0xff * alpha));
        mShadowRight.draw(canvas);
    }
    return result;
}

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//w ww . j a v a  2 s.c o 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.cyanogenmod.filemanager.ui.widgets.DrawerLayout.java

boolean isDrawerView(View child) {
    final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
    final int absGravity = Gravity.getAbsoluteGravity(gravity, child.getLayoutDirection());
    return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
}