resourcesRecyclerView?.viewTreeObserver?.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
//移除监听者,否则Recycler不显示
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
resourcesRecyclerView?.viewTreeObserver?.removeOnGlobalLayoutListener(this)
}
resourcesViewCreated = true
centerToLeftDistance = resourcesRecyclerView!!.width / 2
childViewWidth = SizeUtils.dp2Px(this@VlogActivity, childViewSize.toFloat())
childViewHalfCount = (resourcesRecyclerView!!.width / childViewWidth + 1) / 2
}
})
RecyclerView测量宽高
最新推荐文章于 2023-10-19 22:37:33 发布