Android TextView Get getSizeForString(String text, TextView textView)

Here you can find the source of getSizeForString(String text, TextView textView)

Description

get Size For String

License

Open Source License

Declaration

public static int getSizeForString(String text, TextView textView) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Paint;
import android.graphics.Rect;

import android.widget.TextView;

public class Main {

    public static int getSizeForString(String text, TextView textView) {
        Rect bounds = new Rect();
        Paint textPaint = textView.getPaint();
        textPaint.getTextBounds(text, 0, text.length(), bounds);
        int width = bounds.width();

        return width;
    }/*from   w ww .ja va2s .  com*/
}

Related

  1. getText(TextView textView)
  2. getDouble(TextView view)
  3. getNumber(TextView view)
  4. getString(TextView view)
  5. getEditTextName( ArrayList editTextNames, ArrayList ediTextView, Context ctx)