calculate TextView Height - Android User Interface

Android examples for User Interface:TextView

Description

calculate TextView Height

Demo Code


//package com.java2s;

import android.util.Log;

import android.widget.TextView;

public class Main {
    public static int calculateTextViewHeight(TextView textView) {
        //        if(textView.getVisibility()==View.GONE) return 0;
        int height = textView.getMeasuredHeight();
        if (textView.getText() == null || textView.getText().length() == 0) {
            height = 0;/*www.  j a  v  a 2s. c  o  m*/
        }
        Log.d("calculateTextViewHeight", "text=*" + textView.getText()
                + "* return " + height);
        return height;
    }
}

Related Tutorials