eg:
popView = LayoutInflater.from(this).inflate(R.layout.pop_bubble_1, null);
Log.i("[YT]", "popView-->W"+popView.getMeasuredWidth());
Log.i("[YT]", "popView-->H"+popView.getMeasuredHeight());
popView.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Log.i("[YT]", "popView-->W"+popView.getWidth());
Log.i("[YT]", "popView-->H"+popView.getHeight())
Log.i("[YT]", "popView-->W"+popView.getMeasuredWidth());
Log.i("[YT]", "popView-->H"+popView.getMeasuredHeight());
从上输出可以看出:只有最后两行才是真的popView的宽和高,其他四行输出全是o
总结:想要获取填充布局文件的宽和高,首相需要调用measure方法,然后用getMeasuredWidth()和getMeasuredHeight()取得宽和高。

后,如何获取控件的宽和高?&spm=1001.2101.3001.5002&articleId=7918697&d=1&t=3&u=092f8c68309e4875954ce18a66e8960b)
329

被折叠的 条评论
为什么被折叠?



