Android View.getHeight()返回0

时间:2019-07-06 20:49:26

标签: android kotlin

在onStart()方法中调用View.getHeight()返回0。我的代码如下:

override fun onStart() {
    super.onStart()




    //Configure padding for upper and lower layers
    Log.v("DPTOPX", "The height of active panel in PX is: ${mBinding.activePanel.height}")
    Log.v("DPTOPX", "The height of active panel in DP is: ${dpToPx(mBinding.activePanel.height)}")

    Log.v("DPTOPX", "The height of active panel after converting to PX is: ${pxToDp(mBinding.activePanel.height)}")
}

输出为:

PX中活动面板的高度为:0

DP中活动面板的高度为:0

转换为PX后活动面板的高度为:0

有人可以解释为什么吗?

0 个答案:

没有答案