diff options
| author | 2018-01-04 20:40:04 +0000 | |
|---|---|---|
| committer | 2018-01-04 20:40:04 +0000 | |
| commit | 8d54389b6100d9796398edece98ed3fcef3e2bd8 (patch) | |
| tree | 76cbbbeb371ee97e5354368162f63bcb5d5aa35f | |
| parent | 3157acc3184436495cb8d6c5e5dff36e79add6e9 (diff) | |
| parent | ced7b8dca383b44b2ccef67cba925191a354d500 (diff) | |
Merge "Make print options layout respect RTL"
| -rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java index 7a80a8bd426e..24cf218fd0d8 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java @@ -21,6 +21,7 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; + import com.android.printspooler.R; /** @@ -126,6 +127,7 @@ public final class PrintOptionsLayout extends ViewGroup { protected void onLayout(boolean changed, int l, int t, int r, int b) { final int childCount = getChildCount(); final int rowCount = childCount / mColumnCount + childCount % mColumnCount; + final boolean isLayoutRtl = isLayoutRtl(); int cellStart = getPaddingStart(); int cellTop = getPaddingTop(); @@ -134,7 +136,13 @@ public final class PrintOptionsLayout extends ViewGroup { int rowHeight = 0; for (int col = 0; col < mColumnCount; col++) { - final int childIndex = row * mColumnCount + col; + final int childIndex; + if (isLayoutRtl) { + // if RTL, layout the right most child first + childIndex = row * mColumnCount + (mColumnCount - col - 1); + } else { + childIndex = row * mColumnCount + col; + } if (childIndex >= childCount) { break; @@ -148,14 +156,14 @@ public final class PrintOptionsLayout extends ViewGroup { MarginLayoutParams childParams = (MarginLayoutParams) child.getLayoutParams(); - final int childLeft = cellStart + childParams.getMarginStart(); + final int childStart = cellStart + childParams.getMarginStart(); final int childTop = cellTop + childParams.topMargin; - final int childRight = childLeft + child.getMeasuredWidth(); + final int childEnd = childStart + child.getMeasuredWidth(); final int childBottom = childTop + child.getMeasuredHeight(); - child.layout(childLeft, childTop, childRight, childBottom); + child.layout(childStart, childTop, childEnd, childBottom); - cellStart = childRight + childParams.getMarginEnd(); + cellStart = childEnd + childParams.getMarginEnd(); rowHeight = Math.max(rowHeight, child.getMeasuredHeight() + childParams.topMargin + childParams.bottomMargin); |