Code example for DynamicLayout

Methods: getHeightgetWidth

0
            mTextBounds.setEmpty();
        } else { 
            //Measure text bounds 
            float desired = Layout.getDesiredWidth(mText, mTextPaint);
            mTextLayout = new DynamicLayout(mText, mTextPaint, (int)desired,
                    mTextAlignment, 1.3f, 1.0f, false);
            //Log.i("tttt", "Ancho: " + desired + " textSize: " + getTextSize() 
            //        +" textLayoutWidth: " +mTextLayout.getWidth()); 
            mTextBounds.set(0, 0, mTextLayout.getWidth(), mTextLayout.getHeight());
            Log.i("tttt", "Alto text: " + mTextLayout.getHeight());
        } 
 
        //We may need to be redrawn 
        invalidateSelf();
    } 
     
    public float heightText(String text) {
        float desired = Layout.getDesiredWidth(text, mTextPaint);
        DynamicLayout d = new DynamicLayout(text
                , mTextPaint, (int)desired, mTextAlignment, 1.3f, 1.0f, false);
Experience pair programming with AI  Get Codota for Java