Authorative way to override onMeasure()?

后端 未结 8 2139
眼角桃花
眼角桃花 2020-12-04 07:32

What\'s the correct way of overriding onMeasure()? I\'ve seen various approaches. For example, Professional Android Development uses MeasureSpec to calculate the di

8条回答
  •  抹茶落季
    2020-12-04 07:48

    I guess, setLayoutParams and recalculating the measurements is a workaround to resize the child views correctly, as this is usually done in the derived class's onMeasure.

    However, this rarely works correct (for whatever reason...), better invoke measureChildren (when deriving a ViewGroup) or try something similar when necessary.

提交回复
热议问题