diff options
-rw-r--r-- | src/com/cyngn/theme/widget/FittedTextView.java | 11 | ||||
-rw-r--r-- | src/com/cyngn/theme/widget/LatoTextView.java | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/com/cyngn/theme/widget/FittedTextView.java b/src/com/cyngn/theme/widget/FittedTextView.java index fbe1489..2406a59 100644 --- a/src/com/cyngn/theme/widget/FittedTextView.java +++ b/src/com/cyngn/theme/widget/FittedTextView.java @@ -18,7 +18,11 @@ import android.widget.TextView; */ public class FittedTextView extends TextView { private Paint mPaint; + //If set to true, the text will be resized to fit the view. private boolean mAutoFitText = true; + //Used to instruct whether the text should be expanded to fill out the view, even if the text + //fits without being resized + private boolean mAutoExpand = true; public FittedTextView(Context context) { this(context, null); @@ -41,6 +45,10 @@ public class FittedTextView extends TextView { return mAutoFitText; } + protected void setAutoExpand(boolean autoExpand) { + mAutoExpand = autoExpand; + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -55,8 +63,7 @@ public class FittedTextView extends TextView { } mPaint.set(getPaint()); - //If it fits as is, don't touch it - if (mPaint.measureText(text) <= TARGET_WIDTH) return; + if (mPaint.measureText(text) <= TARGET_WIDTH && !mAutoExpand) return; float max = 200; float min = 2; diff --git a/src/com/cyngn/theme/widget/LatoTextView.java b/src/com/cyngn/theme/widget/LatoTextView.java index 2da46a8..9ced870 100644 --- a/src/com/cyngn/theme/widget/LatoTextView.java +++ b/src/com/cyngn/theme/widget/LatoTextView.java @@ -136,6 +136,7 @@ public class LatoTextView extends FittedTextView { } setTypefaceFromAttrs(fontFamily, styleIndex); + setAutoExpand(false); TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.FittedTextView, 0, 0); try { |