【问题标题】:Difference between View # getWidth() and getMeasuredWidth() [duplicate]视图#getWidth()和getMeasuredWidth()之间的区别[重复]
【发布时间】:2012-09-15 22:11:36
【问题描述】:

可能重复:
What is the difference between getWidth/heigth() and getMeasuredWidth/Heigth() in Android SDK?

在所有情况下,哪个函数会检索视图的实际宽度?这两者有什么区别?谢谢。

【问题讨论】:

标签: android android-layout


【解决方案1】:

gewidth() 用于获取已绘制的视图的宽度(view.getwidth() 或 view.getheight())。 但是, getMeasureWidth() 用于获取尚未绘制的视图宽度。比如 getmeasuredwidth() 和 getmeasureheight()。 例子 : 首先调用 measure view.measure(0,0) 然后你可以将它与 getmeasuredwidth() 和 getmeasureheight() 一起使用

【讨论】:

    猜你喜欢
    • 2012-01-29
    • 2015-12-11
    • 2014-08-16
    • 2011-04-08
    • 2012-11-24
    • 2013-06-05
    • 2021-09-29
    • 2020-05-27
    • 2016-03-23
    相关资源
    最近更新 更多