Example usage for android.view Gravity RIGHT

List of usage examples for android.view Gravity RIGHT

Introduction

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

Prototype

int RIGHT

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

Click Source Link

Document

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

Usage

From source file:com.mods.grx.settings.GrxSettingsActivity.java

private void update_main_fab_position() {

    CoordinatorLayout.LayoutParams p = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
    switch (mFabPosition) {
    case 0://from  www  .  j a v a2 s.  c o m
        p.gravity = Gravity.BOTTOM | Gravity.CENTER;
        break;
    case 1:
        p.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case 2:
        p.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;

    }

    fab.setLayoutParams(p);
}

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

@Override
protected Dialog onCreateDialog(int id) {
    StyledDialog dialog = null;/*w  w  w  . ja v a 2s.c  om*/
    Resources res = getResources();
    StyledDialog.Builder builder = new StyledDialog.Builder(this);

    switch (id) {
    case DIALOG_TAGS_SELECT:
        builder.setTitle(R.string.card_details_tags);
        builder.setPositiveButton(res.getString(R.string.select), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mAddNote) {
                    try {
                        JSONArray ja = new JSONArray();
                        for (String t : selectedTags) {
                            ja.put(t);
                        }
                        mCol.getModels().current().put("tags", ja);
                        mCol.getModels().setChanged();
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    mEditorNote.setTags(selectedTags);
                }
                mCurrentTags = selectedTags;
                updateTags();
            }
        });
        builder.setNegativeButton(res.getString(R.string.cancel), null);

        mNewTagEditText = (EditText) new EditText(this);
        mNewTagEditText.setHint(R.string.add_new_tag);

        InputFilter filter = new InputFilter() {
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                    int dend) {
                for (int i = start; i < end; i++) {
                    if (source.charAt(i) == ' ' || source.charAt(i) == ',') {
                        return "";
                    }
                }
                return null;
            }
        };
        mNewTagEditText.setFilters(new InputFilter[] { filter });

        ImageView mAddTextButton = new ImageView(this);
        mAddTextButton.setImageResource(R.drawable.ic_addtag);
        mAddTextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String tag = mNewTagEditText.getText().toString();
                if (tag.length() != 0) {
                    if (mEditorNote.hasTag(tag)) {
                        mNewTagEditText.setText("");
                        return;
                    }
                    selectedTags.add(tag);
                    actualizeTagDialog(mTagsDialog);
                    mNewTagEditText.setText("");
                }
            }
        });

        FrameLayout frame = new FrameLayout(this);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        params.rightMargin = 10;
        mAddTextButton.setLayoutParams(params);
        frame.addView(mNewTagEditText);
        frame.addView(mAddTextButton);

        builder.setView(frame, false, true);
        dialog = builder.create();
        mTagsDialog = dialog;
        break;

    case DIALOG_DECK_SELECT:
        ArrayList<CharSequence> dialogDeckItems = new ArrayList<CharSequence>();
        // Use this array to know which ID is associated with each
        // Item(name)
        final ArrayList<Long> dialogDeckIds = new ArrayList<Long>();

        ArrayList<JSONObject> decks = mCol.getDecks().all();
        Collections.sort(decks, new JSONNameComparator());
        builder.setTitle(R.string.deck);
        for (JSONObject d : decks) {
            try {
                if (d.getInt("dyn") == 0) {
                    dialogDeckItems.add(d.getString("name"));
                    dialogDeckIds.add(d.getLong("id"));
                }
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        // Convert to Array
        String[] items = new String[dialogDeckItems.size()];
        dialogDeckItems.toArray(items);

        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                long newId = dialogDeckIds.get(item);
                if (mCurrentDid != newId) {
                    if (mAddNote) {
                        try {
                            // TODO: mEditorNote.setDid(newId);
                            mEditorNote.model().put("did", newId);
                            mCol.getModels().setChanged();
                        } catch (JSONException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    mCurrentDid = newId;
                    updateDeck();
                }
            }
        });

        dialog = builder.create();
        mDeckSelectDialog = dialog;
        break;

    case DIALOG_MODEL_SELECT:
        ArrayList<CharSequence> dialogItems = new ArrayList<CharSequence>();
        // Use this array to know which ID is associated with each
        // Item(name)
        final ArrayList<Long> dialogIds = new ArrayList<Long>();

        ArrayList<JSONObject> models = mCol.getModels().all();
        Collections.sort(models, new JSONNameComparator());
        builder.setTitle(R.string.note_type);
        for (JSONObject m : models) {
            try {
                dialogItems.add(m.getString("name"));
                dialogIds.add(m.getLong("id"));
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        // Convert to Array
        String[] items2 = new String[dialogItems.size()];
        dialogItems.toArray(items2);

        builder.setItems(items2, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                long oldModelId;
                try {
                    oldModelId = mCol.getModels().current().getLong("id");
                } catch (JSONException e) {
                    throw new RuntimeException(e);
                }
                long newId = dialogIds.get(item);
                if (oldModelId != newId) {
                    mCol.getModels().setCurrent(mCol.getModels().get(newId));
                    JSONObject cdeck = mCol.getDecks().current();
                    try {
                        cdeck.put("mid", newId);
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    mCol.getDecks().save(cdeck);
                    int size = mEditFields.size();
                    String[] oldValues = new String[size];
                    for (int i = 0; i < size; i++) {
                        oldValues[i] = mEditFields.get(i).getText().toString();
                    }
                    setNote();
                    resetEditFields(oldValues);
                    mTimerHandler.removeCallbacks(checkDuplicatesRunnable);
                    duplicateCheck(false);
                }
            }
        });
        dialog = builder.create();
        break;

    case DIALOG_RESET_CARD:
        builder.setTitle(res.getString(R.string.reset_card_dialog_title));
        builder.setMessage(res.getString(R.string.reset_card_dialog_message));
        builder.setPositiveButton(res.getString(R.string.yes), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // for (long cardId :
                // mDeck.getCardsFromFactId(mEditorNote.getId())) {
                // mDeck.cardFromId(cardId).resetCard();
                // }
                // mDeck.reset();
                // setResult(Reviewer.RESULT_EDIT_CARD_RESET);
                // mCardReset = true;
                // Themes.showThemedToast(CardEditor.this,
                // getResources().getString(
                // R.string.reset_card_dialog_confirmation), true);
            }
        });
        builder.setNegativeButton(res.getString(R.string.no), null);
        builder.setCancelable(true);
        dialog = builder.create();
        break;

    case DIALOG_INTENT_INFORMATION:
        dialog = createDialogIntentInformation(builder, res);
    }

    return dialog;
}

From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.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();
    int clipTop = 0, clipBottom = getHeight();

    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.  j  a  v  a2 s .co  m*/
            switch (getDrawerViewAbsoluteGravity(v)) {
            case Gravity.LEFT:
                Log.i(TAG, "drawChild() -- 1");
                if (checkDrawerViewAbsoluteGravity(v, Gravity.LEFT)) {
                    final int vright = v.getRight();
                    if (vright > clipLeft)
                        clipLeft = vright;
                }
                break;
            case Gravity.RIGHT:
                Log.i(TAG, "drawChild() -- 2");
                if (checkDrawerViewAbsoluteGravity(v, Gravity.RIGHT)) {
                    final int vleft = v.getLeft();
                    if (vleft < clipRight)
                        clipRight = vleft;
                }
                break;
            case Gravity.TOP:
                Log.i(TAG, "drawChild() -- 3");
                if (checkDrawerViewAbsoluteGravity(v, Gravity.TOP)) {
                    final int vbottom = v.getBottom();
                    if (vbottom > clipTop) {
                        clipTop = vbottom;
                    }
                }
                break;
            case Gravity.BOTTOM:
                Log.i(TAG, "drawChild() -- 4");
                if (checkDrawerViewAbsoluteGravity(v, Gravity.BOTTOM)) {
                    final int vtop = v.getTop();
                    if (vtop < clipBottom) {
                        clipBottom = vtop;
                    }
                }
                break;
            default:
                Log.i(TAG, "drawChild() -- 5");
                final int vtop = v.getTop();
                if (vtop < clipBottom) {
                    clipBottom = vtop;
                }
                break;
            }
        }
        canvas.clipRect(clipLeft, clipTop, clipRight, clipBottom);
    }
    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, clipTop, clipRight, clipBottom, mScrimPaint);
    } else if (mShadowLeft != null && checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) {
        Log.i(TAG, "drawChild() -- 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);
    } else if (mShadowTop != null && checkDrawerViewAbsoluteGravity(child, Gravity.TOP)) {
        Log.i(TAG, "drawChild() -- Gravity.TOP");
        final int shadowHeight = mShadowTop.getIntrinsicHeight();
        final int childBottom = child.getBottom();
        final int drawerPeekDistance = mTopDragger.getEdgeSize();
        final float alpha = Math.max(0, Math.min((float) childBottom / drawerPeekDistance, 1.f));
        mShadowTop.setBounds(child.getLeft(), childBottom, child.getRight(), childBottom + shadowHeight);
        mShadowTop.setAlpha((int) (0xff * alpha));
        mShadowTop.draw(canvas);
    } else if (mShadowBottom != null && checkDrawerViewAbsoluteGravity(child, Gravity.BOTTOM)) {
        Log.i(TAG, "drawChild() -- Gravity.BOTTOM");
        final int shadowHeight = mShadowBottom.getIntrinsicWidth();
        final int childTop = child.getTop();
        final int showing = getHeight() - childTop;
        final int drawerPeekDistance = mBottomDragger.getEdgeSize();
        final float alpha = Math.max(0, Math.min((float) showing / drawerPeekDistance, 1.f));
        mShadowRight.setBounds(child.getLeft(), childTop - shadowHeight, child.getRight(), childTop);
        mShadowRight.setAlpha((int) (0xff * alpha));
        mShadowRight.draw(canvas);
    }
    return result;
}

From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java

private void computeInsets(int dx, int dy) {
    final int layoutDirection = getLayoutDirection();
    final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);

    switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.LEFT:
        mHorizontalInset = 0;/*from  w w w  .  ja v  a  2s .c om*/
        break;
    case Gravity.RIGHT:
        mHorizontalInset = dx;
        break;
    case Gravity.CENTER_HORIZONTAL:
    default:
        mHorizontalInset = dx / 2;
        break;
    }
    switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.TOP:
        mVerticalInset = 0;
        break;
    case Gravity.BOTTOM:
        mVerticalInset = dy;
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        mVerticalInset = dy / 2;
        break;
    }
}

From source file:android.support.design.widget.CoordinatorLayout.java

private void getDesiredAnchoredChildRectWithoutConstraints(View child, int layoutDirection, Rect anchorRect,
        Rect out, LayoutParams lp, int childWidth, int childHeight) {
    final int absGravity = GravityCompat.getAbsoluteGravity(resolveAnchoredChildGravity(lp.gravity),
            layoutDirection);/*w  w w  .  jav  a2 s . c  o  m*/
    final int absAnchorGravity = GravityCompat.getAbsoluteGravity(resolveGravity(lp.anchorGravity),
            layoutDirection);

    final int hgrav = absGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    final int vgrav = absGravity & Gravity.VERTICAL_GRAVITY_MASK;
    final int anchorHgrav = absAnchorGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    final int anchorVgrav = absAnchorGravity & Gravity.VERTICAL_GRAVITY_MASK;

    int left;
    int top;

    // Align to the anchor. This puts us in an assumed right/bottom child view gravity.
    // If this is not the case we will subtract out the appropriate portion of
    // the child size below.
    switch (anchorHgrav) {
    default:
    case Gravity.LEFT:
        left = anchorRect.left;
        break;
    case Gravity.RIGHT:
        left = anchorRect.right;
        break;
    case Gravity.CENTER_HORIZONTAL:
        left = anchorRect.left + anchorRect.width() / 2;
        break;
    }

    switch (anchorVgrav) {
    default:
    case Gravity.TOP:
        top = anchorRect.top;
        break;
    case Gravity.BOTTOM:
        top = anchorRect.bottom;
        break;
    case Gravity.CENTER_VERTICAL:
        top = anchorRect.top + anchorRect.height() / 2;
        break;
    }

    // Offset by the child view's gravity itself. The above assumed right/bottom gravity.
    switch (hgrav) {
    default:
    case Gravity.LEFT:
        left -= childWidth;
        break;
    case Gravity.RIGHT:
        // Do nothing, we're already in position.
        break;
    case Gravity.CENTER_HORIZONTAL:
        left -= childWidth / 2;
        break;
    }

    switch (vgrav) {
    default:
    case Gravity.TOP:
        top -= childHeight;
        break;
    case Gravity.BOTTOM:
        // Do nothing, we're already in position.
        break;
    case Gravity.CENTER_VERTICAL:
        top -= childHeight / 2;
        break;
    }

    out.set(left, top, left + childWidth, top + childHeight);
}

From source file:com.jecelyin.editor.v2.widget.AnyDrawerLayout.java

/**
 * Simple gravity to string - only supports LEFT and RIGHT for debugging output.
 *
 * @param gravity Absolute gravity value
 * @return LEFT or RIGHT as appropriate, or a hex string
 *///www .j a  v a 2s  .  c o  m
static String gravityToString(@EdgeGravity int gravity) {
    if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
        return "LEFT";
    }
    if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
        return "RIGHT";
    }
    if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        return "BOTTOM";
    }
    return Integer.toHexString(gravity);
}

From source file:com.hb.hkm.slidinglayer.SlidLayer.java

private void adjustLayoutParams() {

    ViewGroup.LayoutParams baseParams = getLayoutParams();

    if (baseParams instanceof LayoutParams) {

        LayoutParams layoutParams = (LayoutParams) baseParams;

        switch (mScreenSide) {
        case STICK_TO_BOTTOM:
            layoutParams.gravity = Gravity.BOTTOM;
            break;
        case STICK_TO_LEFT:
            layoutParams.gravity = Gravity.LEFT;
            break;
        case STICK_TO_RIGHT:
            layoutParams.gravity = Gravity.RIGHT;
            break;
        case STICK_TO_TOP:
            layoutParams.gravity = Gravity.TOP;
            break;
        }/*  w  w  w. j av a  2s  . com*/
        setLayoutParams(baseParams);

    } else if (baseParams instanceof RelativeLayout.LayoutParams) {

        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) baseParams;

        switch (mScreenSide) {
        case STICK_TO_BOTTOM:
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            break;
        case STICK_TO_LEFT:
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            break;
        case STICK_TO_RIGHT:
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            break;
        case STICK_TO_TOP:
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            break;
        }
    }

}

From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java

/**
 * Given the desired width and height of the ring and the allocated width and height, compute
 * how much we need to scale the ring./*  w  w  w .  j  a v a2 s  . c  o m*/
 */
private float computeScaleFactor(int desiredWidth, int desiredHeight, int actualWidth, int actualHeight) {

    // Return unity if scaling is not allowed.
    if (!mAllowScaling)
        return 1f;

    final int layoutDirection = getLayoutDirection();
    final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);

    float scaleX = 1f;
    float scaleY = 1f;

    // We use the gravity as a cue for whether we want to scale on a particular axis.
    // We only scale to fit horizontally if we're not pinned to the left or right. Likewise,
    // we only scale to fit vertically if we're not pinned to the top or bottom. In these
    // cases, we want the ring to hang off the side or top/bottom, respectively.
    switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.LEFT:
    case Gravity.RIGHT:
        break;
    case Gravity.CENTER_HORIZONTAL:
    default:
        if (desiredWidth > actualWidth) {
            scaleX = (1f * actualWidth - mMaxTargetWidth) / (desiredWidth - mMaxTargetWidth);
        }
        break;
    }
    switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.TOP:
    case Gravity.BOTTOM:
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        if (desiredHeight > actualHeight) {
            scaleY = (1f * actualHeight - mMaxTargetHeight) / (desiredHeight - mMaxTargetHeight);
        }
        break;
    }
    return Math.min(scaleX, scaleY);
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    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) {
                continue;
            }/*from  w ww.j av  a 2 s  . c om*/

            if (checkDrawerViewAbsoluteGravity(v, Gravity.LEFT)) {
                final int vright = v.getRight();
                if (vright > clipLeft)
                    clipLeft = vright;
            } else {
                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) {
        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)) {
        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)) {
        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.tylz.jiaoyanglogistics.view.LazyViewPager.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mInLayout = true;//from   ww  w  . j a  v  a 2  s  .  co  m
    populate();
    mInLayout = false;

    final int count = getChildCount();
    int width = r - l;
    int height = b - t;
    int paddingLeft = getPaddingLeft();
    int paddingTop = getPaddingTop();
    int paddingRight = getPaddingRight();
    int paddingBottom = getPaddingBottom();
    final int scrollX = getScrollX();

    int decorCount = 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            ItemInfo ii;
            int childLeft = 0;
            int childTop = 0;
            if (lp.isDecor) {
                final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
                final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
                switch (hgrav) {
                default:
                    childLeft = paddingLeft;
                    break;
                case Gravity.LEFT:
                    childLeft = paddingLeft;
                    paddingLeft += child.getMeasuredWidth();
                    break;
                case Gravity.CENTER_HORIZONTAL:
                    childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft);
                    break;
                case Gravity.RIGHT:
                    childLeft = width - paddingRight - child.getMeasuredWidth();
                    paddingRight += child.getMeasuredWidth();
                    break;
                }
                switch (vgrav) {
                default:
                    childTop = paddingTop;
                    break;
                case Gravity.TOP:
                    childTop = paddingTop;
                    paddingTop += child.getMeasuredHeight();
                    break;
                case Gravity.CENTER_VERTICAL:
                    childTop = Math.max((height - child.getMeasuredHeight()) / 2, paddingTop);
                    break;
                case Gravity.BOTTOM:
                    childTop = height - paddingBottom - child.getMeasuredHeight();
                    paddingBottom += child.getMeasuredHeight();
                    break;
                }
                childLeft += scrollX;
                decorCount++;
                child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(),
                        childTop + child.getMeasuredHeight());
            } else if ((ii = infoForChild(child)) != null) {
                int loff = (width + mPageMargin) * ii.position;
                childLeft = paddingLeft + loff;
                childTop = paddingTop;
                if (DEBUG) {
                    Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + ","
                            + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight());
                }
                child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(),
                        childTop + child.getMeasuredHeight());
            }
        }
    }
    mTopPageBounds = paddingTop;
    mBottomPageBounds = height - paddingBottom;
    mDecorChildCount = decorCount;
    mFirstLayout = false;
}