标签:android
在onCreate中无法通过getHeight方法获取View的宽高。我们可以通过MeasureSpec实现。
int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
textView.measure(w, h);
int width =textView.getMeasuredWidth();
int height =textView.getMeasuredHeight();
标签:android
原文地址:http://6169621.blog.51cto.com/6159621/1618587