自学内容网 自学内容网

【Android】setLayoutParams Sometimes Not Working

setLayoutParams may fail when called during another layout period

or inner of a callback function in layout period

we can use post to setLayoutParams in next layout period

binding.image.post {
    val fixedHeight = (binding.image.measuredWidth / ratio).toInt()
    binding.image.setLayoutParams { height = fixedHeight }
}

原文地址:https://blog.csdn.net/u013718730/article/details/143199736

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!