getWidth() and getHeight() always returning 0. Custom view

前端 未结 7 2034
悲哀的现实
悲哀的现实 2020-12-09 09:11

In a Fragment, I am inflating a Layout with multiple child View. I need to get the dimensions (width and height) of one of them which is a custom view.

Inside the

7条回答
  •  爱一瞬间的悲伤
    2020-12-09 09:35

    Try calling

    culoide.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);

    first, then try getWidth() and getHeight()

提交回复
热议问题