Example usage for android.view View LAYOUT_DIRECTION_RTL

List of usage examples for android.view View LAYOUT_DIRECTION_RTL

Introduction

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

Prototype

int LAYOUT_DIRECTION_RTL

To view the source code for android.view View LAYOUT_DIRECTION_RTL.

Click Source Link

Document

Horizontal layout direction of this view is from Right to Left.

Usage

From source file:android.support.v17.leanback.widget.GridLayoutManager.java

private void layoutChild(int rowIndex, View v, int start, int end, int startSecondary) {
    if (TRACE)/*from w  w  w  .  jav  a  2s . co m*/
        TraceHelper.beginSection("layoutChild");
    int sizeSecondary = mOrientation == HORIZONTAL ? getDecoratedMeasuredHeightWithMargin(v)
            : getDecoratedMeasuredWidthWithMargin(v);
    if (mFixedRowSizeSecondary > 0) {
        sizeSecondary = Math.min(sizeSecondary, mFixedRowSizeSecondary);
    }
    final int verticalGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK;
    final int horizontalGravity = (mReverseFlowPrimary || mReverseFlowSecondary)
            ? Gravity.getAbsoluteGravity(mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK,
                    View.LAYOUT_DIRECTION_RTL)
            : mGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    if (mOrientation == HORIZONTAL && verticalGravity == Gravity.TOP
            || mOrientation == VERTICAL && horizontalGravity == Gravity.LEFT) {
        // do nothing
    } else if (mOrientation == HORIZONTAL && verticalGravity == Gravity.BOTTOM
            || mOrientation == VERTICAL && horizontalGravity == Gravity.RIGHT) {
        startSecondary += getRowSizeSecondary(rowIndex) - sizeSecondary;
    } else if (mOrientation == HORIZONTAL && verticalGravity == Gravity.CENTER_VERTICAL
            || mOrientation == VERTICAL && horizontalGravity == Gravity.CENTER_HORIZONTAL) {
        startSecondary += (getRowSizeSecondary(rowIndex) - sizeSecondary) / 2;
    }
    int left, top, right, bottom;
    if (mOrientation == HORIZONTAL) {
        left = start;
        top = startSecondary;
        right = end;
        bottom = startSecondary + sizeSecondary;
    } else {
        top = start;
        left = startSecondary;
        bottom = end;
        right = startSecondary + sizeSecondary;
    }
    LayoutParams params = (LayoutParams) v.getLayoutParams();
    layoutDecoratedWithMargins(v, left, top, right, bottom);
    // Now super.getDecoratedBoundsWithMargins() includes the extra space for optical bounds,
    // subtracting it from value passed in layoutDecoratedWithMargins(), we can get the optical
    // bounds insets.
    super.getDecoratedBoundsWithMargins(v, sTempRect);
    params.setOpticalInsets(left - sTempRect.left, top - sTempRect.top, sTempRect.right - right,
            sTempRect.bottom - bottom);
    updateChildAlignments(v);
    if (TRACE)
        TraceHelper.endSection();
}