From a84a728d17c439d83a6ebd78e3e54b8480804600 Mon Sep 17 00:00:00 2001 From: Spike Sprague Date: Thu, 13 Feb 2014 10:35:37 -0800 Subject: [PATCH] doubling padding on intent capture review cancel and retake buttons bug: 13006473 Change-Id: I881cc714c6a0fe9b1e4eebca123b0873f47a837f --- res/layout/bottom_bar_contents.xml | 4 ++-- src/com/android/camera/ui/TopRightWeightedLayout.java | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/res/layout/bottom_bar_contents.xml b/res/layout/bottom_bar_contents.xml index 6ef01f9e4..a4c8d7849 100644 --- a/res/layout/bottom_bar_contents.xml +++ b/res/layout/bottom_bar_contents.xml @@ -47,7 +47,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|center_vertical" - android:padding="12dp" + android:paddingLeft="24dp" android:src="@drawable/ic_back" android:background="@null" android:contentDescription="@string/retake_button_description" /> @@ -65,7 +65,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" - android:padding="12dp" + android:paddingRight="24dp" android:src="@drawable/ic_cancel" android:background="@null" android:contentDescription="@string/cancel_button_description" /> diff --git a/src/com/android/camera/ui/TopRightWeightedLayout.java b/src/com/android/camera/ui/TopRightWeightedLayout.java index 97b593463..317cb3e5f 100644 --- a/src/com/android/camera/ui/TopRightWeightedLayout.java +++ b/src/com/android/camera/ui/TopRightWeightedLayout.java @@ -59,14 +59,14 @@ public class TopRightWeightedLayout extends LinearLayout { if (isPortrait && !isHorizontal) { // Portrait orientation is out of sync, setting to horizontal // and reversing children - fixGravity(LinearLayout.HORIZONTAL); + fixGravityAndPadding(LinearLayout.HORIZONTAL); setOrientation(LinearLayout.HORIZONTAL); reverseChildren(); requestLayout(); } else if (!isPortrait && isHorizontal) { // Landscape orientation is out of sync, setting to vertical // and reversing children - fixGravity(LinearLayout.VERTICAL); + fixGravityAndPadding(LinearLayout.VERTICAL); setOrientation(LinearLayout.VERTICAL); reverseChildren(); requestLayout(); @@ -93,9 +93,12 @@ public class TopRightWeightedLayout extends LinearLayout { * right for top * center horizontal for center vertical * etc + * + * also swap left|right padding for bottom|top */ - private void fixGravity(int direction) { + private void fixGravityAndPadding(int direction) { for (int i = 0; i < getChildCount(); i++) { + // gravity swap View v = getChildAt(i); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) v.getLayoutParams(); int gravity = layoutParams.gravity; @@ -140,6 +143,13 @@ public class TopRightWeightedLayout extends LinearLayout { } layoutParams.gravity = gravity; + + // padding swap + int paddingLeft = v.getPaddingLeft(); + int paddingTop = v.getPaddingTop(); + int paddingRight = v.getPaddingRight(); + int paddingBottom = v.getPaddingBottom(); + v.setPadding(paddingBottom, paddingRight, paddingTop, paddingLeft); } } } \ No newline at end of file -- 2.11.0