Return the width of the TextView. - Android User Interface

Android examples for User Interface:TextView

Description

Return the width of the TextView.

Demo Code


import android.widget.TextView;

public class Main {
  /**//from  w ww .  j  a  v  a 2 s  . c o m
   * Return the width of the testText.
   * 
   * @return the width of testText placed in the textView
   */
  private static float getTextSize(TextView textView, String testText) {
    return textView.getPaint().measureText(testText);
  }
}

Related Tutorials