diff options
| author | Sai Cheemalapati <saicheems@google.com> | 2014-06-23 11:30:45 -0700 |
|---|---|---|
| committer | Sai Cheemalapati <saicheems@google.com> | 2014-06-23 16:20:41 -0700 |
| commit | 9a17f0e3e1a3957c8c2b530171281943bec435f1 (patch) | |
| tree | 67f22f19d022bbefe9ac2b54bfa5ebd6ac9e03e7 /src/com/android/phone/common/util/ViewUtil.java | |
| parent | 13b8948c0cc543f62a68fa32c4692ba16a2e93c6 (diff) | |
| download | packages_apps_PhoneCommon-9a17f0e3e1a3957c8c2b530171281943bec435f1.tar.gz packages_apps_PhoneCommon-9a17f0e3e1a3957c8c2b530171281943bec435f1.tar.bz2 packages_apps_PhoneCommon-9a17f0e3e1a3957c8c2b530171281943bec435f1.zip | |
Add text resizing to InCallUI name field (2/2).
Set maximum size of primary name text to 45 pt.
Scales down to minimum size of 34 pt.
Bug: 15457502
Change-Id: I12dabf66cbefaa4ad458abdb910e8b0417f5b234
Diffstat (limited to 'src/com/android/phone/common/util/ViewUtil.java')
| -rw-r--r-- | src/com/android/phone/common/util/ViewUtil.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/com/android/phone/common/util/ViewUtil.java b/src/com/android/phone/common/util/ViewUtil.java index 171eee0..34b6274 100644 --- a/src/com/android/phone/common/util/ViewUtil.java +++ b/src/com/android/phone/common/util/ViewUtil.java @@ -18,9 +18,12 @@ package com.android.phone.common.util; import android.content.res.Resources; import android.graphics.Outline; +import android.graphics.Paint; +import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; +import android.widget.TextView; import com.android.phone.common.R; @@ -94,4 +97,16 @@ public class ViewUtil { listView.getPaddingEnd(), listView.getPaddingBottom() + fabPadding); listView.setClipToPadding(false); } + + public static void resizeText(TextView textView, int originalTextSize, int minTextSize) { + final Paint paint = textView.getPaint(); + final int width = textView.getWidth(); + if (width == 0) return; + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalTextSize); + float ratio = width / paint.measureText(textView.getText().toString()); + if (ratio <= 1.0f) { + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, + Math.max(minTextSize, originalTextSize * ratio)); + } + } } |
