【发布时间】:2015-04-02 02:46:28
【问题描述】:
我正在使用它来测量视图大小:
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(toExpandVystrahy.getWidth(), View.MeasureSpec.EXACTLY);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
textVystrahy.measure(widthMeasureSpec, heightMeasureSpec);
int vystrahyHeight = textVystrahy.getMeasuredHeight();
我的onActivityCreated 内部片段中有这段代码。当我第一次启动我的应用程序时,它工作得很好并且可以正确测量。但是,当我更改屏幕方向并从片段内部的onActivityCreated 运行此方法时,它仍然返回与旋转前相同的值。那么屏幕旋转后我应该在哪里测量视图高度? onActivityCreated 位置不对吗?
感谢转发
【问题讨论】: