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
This commit is contained in:
Fan Zhang
2016-07-29 13:35:41 -07:00
parent 7f37f2693f
commit dd5469e488
2 changed files with 8 additions and 5 deletions

View File

@@ -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">
<Space
android:id="@+id/bottom_label_space"
android:layout_width="@dimen/usage_graph_labels_width"
android:layout_height="wrap_content"/>
<include android:id="@+id/label_start"
layout="@layout/usage_side_label" />

View File

@@ -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);
}