Example usage for android.text SpannedString toString

List of usage examples for android.text SpannedString toString

Introduction

In this page you can find the example usage for android.text SpannedString toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:org.de.jmg.learn._MainActivity.java

void SetTxtStatusSize(int width) {
    if (width == 0)
        width = mainView.getWidth();//www.  ja  v  a  2 s .  c  o  m
    if (width == 0 && _OriginalWidth == 0)
        return;
    if (width == 0)
        width = _OriginalWidth;
    _OriginalWidth = width;
    TextView t = _txtStatus;
    Paint p = new Paint();
    if (t.getText() instanceof SpannedString) {
        p.setTextSize(t.getTextSize());
        SpannedString s = (SpannedString) t.getText();
        width = width - width / (_isSmallDevice ? 4 : 5);
        float measuredWidth = p.measureText(s.toString());
        if (measuredWidth != width) {
            float scaleA = (float) width / measuredWidth;
            if (libString.IsNullOrEmpty(_vok.getFileName()))
                scaleA *= .75f;
            if (scaleA < .5f)
                scaleA = .5f;
            if (scaleA > 2.0f)
                scaleA = 2.0f;
            float size = t.getTextSize();
            t.setTextSize(TypedValue.COMPLEX_UNIT_PX, size * scaleA);
        }

    }
}