From dd5469e48898a23894b363dbc1d22d3f7af50796 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Fri, 29 Jul 2016 13:35:41 -0700 Subject: [PATCH] Align bottom text with battery graph in RTL layout. Bug: 30161009 Bottom text (estmitated remaining battery time) should be stay under the battery graph in RTL. To help alignment, we use a spacer view to the left or right of text depending on layout direction. Change-Id: Iaf706c1a963246e7f04764e5f24e6cb4bf3d2bbf --- packages/SettingsLib/res/layout/usage_view.xml | 6 ++++-- .../SettingsLib/src/com/android/settingslib/graph/UsageView.java | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/SettingsLib/res/layout/usage_view.xml b/packages/SettingsLib/res/layout/usage_view.xml index aa1a046974f0..1d56668a82d0 100644 --- a/packages/SettingsLib/res/layout/usage_view.xml +++ b/packages/SettingsLib/res/layout/usage_view.xml @@ -71,9 +71,11 @@ android:id="@+id/bottom_label_group" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingStart="@dimen/usage_graph_labels_width" android:orientation="horizontal"> - + diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/UsageView.java b/packages/SettingsLib/src/com/android/settingslib/graph/UsageView.java index ee1821dc6bbe..c6a45bcf1e9f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/graph/UsageView.java +++ b/packages/SettingsLib/src/com/android/settingslib/graph/UsageView.java @@ -71,10 +71,11 @@ public class UsageView extends FrameLayout { layout.addView(labels); // Set gravity. labels.setGravity(Gravity.END); - // Swap the bottom label padding + // Swap the bottom space order. LinearLayout bottomLabels = (LinearLayout) findViewById(R.id.bottom_label_group); - bottomLabels.setPadding(bottomLabels.getPaddingRight(), bottomLabels.getPaddingTop(), - bottomLabels.getPaddingLeft(), bottomLabels.getPaddingBottom()); + View bottomSpace = bottomLabels.findViewById(R.id.bottom_label_space); + bottomLabels.removeView(bottomSpace); + bottomLabels.addView(bottomSpace); } else if (gravity != Gravity.START) { throw new IllegalArgumentException("Unsupported gravity " + gravity); } -- 2.11.0