+
81
-

andriod开发中如何获取view的宽度高度?

andriod开发中如何获取view的宽度高度?

高手回复

+
1
-
private int mHeaderViewHeight;
private View mHeaderView;

mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {

mHeaderViewHeight = mHeaderView.getHeight();
mHeaderView.getViewTreeObserver()
.removeGlobalOnLayoutListener(this);
}
});
by ppzhuzhu
我知道答案,我要回答