Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

import android.widget.TextView;

public class Main {
    /**
     * Method getTextWith() used to get the TextView's Content
     * 
     * @param textView
     *            The processed TextView.
     * @param text
     *            The Content of TextView
     * @return
     */
    public static int getTextWidth(TextView textView, String text) {
        Rect bounds = new Rect();
        Paint textPaint = textView.getPaint();
        textPaint.getTextBounds(text, 0, text.length(), bounds);
        return bounds.width();
    }
}