diff options
author | linyuh <linyuh@google.com> | 2017-11-06 18:08:00 -0800 |
---|---|---|
committer | Zachary Heidepriem <zachh@google.com> | 2017-11-11 12:18:05 -0800 |
commit | 7f3f33c6f7ee64dda756c3a51a610c9565a7ee63 (patch) | |
tree | a0fb688610549589fdff60123817caa59ba426a9 /java/com/android/dialer/dialpadview/DialpadView.java | |
parent | c2ea695927a5866cea732ea784a8ee4473b8ba19 (diff) |
Use layout_gravity to horizontally center each dialpad key in landscape mode.
Test: Manual
PiperOrigin-RevId: 174792372
Change-Id: I80ff3852c40cd532fdd2ed332e8b84ffb211a6e2
Diffstat (limited to 'java/com/android/dialer/dialpadview/DialpadView.java')
-rw-r--r-- | java/com/android/dialer/dialpadview/DialpadView.java | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/java/com/android/dialer/dialpadview/DialpadView.java b/java/com/android/dialer/dialpadview/DialpadView.java index 5728f8132..73abd1274 100644 --- a/java/com/android/dialer/dialpadview/DialpadView.java +++ b/java/com/android/dialer/dialpadview/DialpadView.java @@ -275,12 +275,11 @@ public class DialpadView extends LinearLayout { } /** - * Adjust key widths to align keys in each column. + * Make the widths of all keys the same. * - * <p>When the device is in landscape mode, we first find the maximum among a pre-defined width - * and the width of each key layout. Then we adjust the width of each layout's horizontal - * placeholder to align keys in each column. This is to accommodate the scenario where not all - * letters associated with a key can be displayed in one line due to large font size. + * <p>When the device is in landscape mode, we first find the maximum width among key layouts. + * Then we adjust the width of each layout's horizontal placeholder so that each key has the same + * width. * * <p>This method should be called after the sizes of related layouts have been calculated by the * framework. @@ -288,27 +287,11 @@ public class DialpadView extends LinearLayout { private void adjustKeyWidths() { Assert.checkState(isLandscapeMode()); - // A pre-defined minimum width for the letters shown beside a key. - final int minimumKeyLettersWidth = - getContext().getResources().getDimensionPixelSize(R.dimen.dialpad_key_text_width); - - // The maximum width of the key layouts. A key layout includes both the number and the letters. int maxWidth = 0; - for (int buttonId : BUTTON_IDS) { DialpadKeyButton dialpadKey = (DialpadKeyButton) findViewById(buttonId); LinearLayout keyLayout = (LinearLayout) dialpadKey.findViewById(R.id.dialpad_key_layout); - TextView keyLettersView = (TextView) keyLayout.findViewById(R.id.dialpad_key_letters); - if (keyLettersView != null && keyLettersView.getWidth() < minimumKeyLettersWidth) { - // If the width of the letters is less than the pre-defined minimum, use the pre-defined - // minimum to obtain the maximum width. - maxWidth = - Math.max( - maxWidth, - keyLayout.getWidth() - keyLettersView.getWidth() + minimumKeyLettersWidth); - } else { - maxWidth = Math.max(maxWidth, keyLayout.getWidth()); - } + maxWidth = Math.max(maxWidth, keyLayout.getWidth()); } for (int buttonId : BUTTON_IDS) { |