Java tutorial
//package com.java2s; /* * This is the source code of Telegram for Android v. 1.4.x. * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * * Copyright Nikolai Kudashov, 2013-2014. */ import android.graphics.Rect; import android.text.TextPaint; import android.widget.TextView; public class Main { public static int getTextViewMeasureWidth(TextView textView, String text) { if (textView == null) return 0; TextPaint paint = textView.getPaint(); Rect rect = new Rect(); paint.getTextBounds(text, 0, text.length(), rect); return Math.abs(rect.right - rect.left); } }