else if (alignment == 2) { _alignment = Layout.Alignment.ALIGN_OPPOSITE; } layout = new StaticLayout(text, paint, textWidth, _alignment, 1, 0, false); textHeight = (int)Math.ceil(layout.getHeight()); if (textHeight > maxHeightPixels) { textHeight = maxHeightPixels; } else if (textHeight <= 0) { textHeight = 1; } } private void prepare() { paint = new TextPaint(); Typeface typeface = getTypeface();