方法一:
TextView tv = (TextView) findViewById(R.id.tv);
int h = View.MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
int w = View.MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
tv.measure(w, h);
int height = tv.getMeasuredHeight();
int width = tv.getMeasuredWidth();
Log.i("lw", "height ="+height+"width ="+width);
方法二:
TextView tv = (TextView) findViewById(R.id.tv);
LayoutParams params = (LayoutParams) tv.getLayoutParams();
int width2 = params.width;
int height2 = params.height;
Log.i("lw", "height2 ="+height2+"width2 ="+width2);