diff --git a/res/layout/calc_display.xml b/res/layout/calc_display.xml index 52ffaf29..c4e6a164 100644 --- a/res/layout/calc_display.xml +++ b/res/layout/calc_display.xml @@ -10,5 +10,7 @@ xmlns:a="http://schemas.android.com/apk/res/android" a:id="@+id/calculatorDisplay" style="@style/display_style" - a:scrollHorizontally="true" + a:inputType="textMultiLine" + a:maxLines="3" + a:scrollHorizontally="false" a:scrollbars="none"/> \ No newline at end of file diff --git a/res/values/styles-common.xml b/res/values/styles-common.xml index 2cd67c0a..afe3576a 100644 --- a/res/values/styles-common.xml +++ b/res/values/styles-common.xml @@ -58,7 +58,7 @@ diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java index c962d8fa..6e61f444 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java @@ -84,7 +84,7 @@ public enum CalculatorModel implements CursorControl, HistoryControl height) { // Draw using a static layout StaticLayout layout = new StaticLayout(text, textPaint, width, Alignment.ALIGN_NORMAL, spacingMult, spacingAdd, false); - layout.draw(sTextResizeCanvas); + layout.draw(textResizeCanvas); int lastLine = layout.getLineForVertical(height) - 1; int start = layout.getLineStart(lastLine); int end = layout.getLineEnd(lastLine); float lineWidth = layout.getLineWidth(lastLine); - float ellipseWidth = textPaint.measureText(mEllipsis); + float ellipseWidth = textPaint.measureText(ellipsis); // Trim characters off until we have enough room to draw the ellipsis while (width < lineWidth + ellipseWidth) { lineWidth = textPaint.measureText(text.subSequence(start, --end + 1).toString()); } - setText(text.subSequence(0, end) + mEllipsis); + setText(text.subSequence(0, end) + ellipsis); } // Some devices try to auto adjust line spacing, so force default line spacing // and invalidate the layout as a side effect textPaint.setTextSize(newTextSize); - //setLineSpacing(spacingAdd, spacingMult); + setLineSpacing(spacingAdd, spacingMult); // Notify the listener if registered - if (mTextResizeListener != null) { - mTextResizeListener.onTextResize(this, oldTextSize, newTextSize); + if (textResizeListener != null) { + textResizeListener.onTextResize(this, oldTextSize, newTextSize); } // Reset force resize flag - mNeedsResize = false; + needsResize = false; } // Set the text size of the text paint object and use a static layout to render text off screen before measuring @@ -263,7 +263,7 @@ public class AutoResizeTextView extends TextView { paint.setTextSize(textSize); // Draw using a static layout StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, spacingMult, spacingAdd, false); - layout.draw(sTextResizeCanvas); + layout.draw(textResizeCanvas); return layout.getHeight(); } }