获取控件的长宽
2023-08-31 本文已影响0人
皓皓amous
txtA.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
int height = txtA.getMeasuredHeight();
int width = txtA.getMeasuredWidth();
txtA.getViewTreeObserver().removeOnPreDrawListener(this);
return true;
}
});