PHP技术,网站开发,PHP,PHP学习,Python学习,PHP开发,人工智能,大数据服务

PHP » APP开发 » android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams

android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams

此文被围观712日期: 2021-03-04 分类 : APP开发  标签:  ····

android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams


动态设置FrameLayout的属性时报错,上级元素是LinearLayout


private fun setFrameLayoutStyle(frameLayout: FrameLayout, top: Number) {
    val frameParams = frameLayout.layoutParams as LinearLayout.LayoutParams
    frameParams.topMargin = top as Int
    frameLayout.layoutParams = frameParams
}


Android动态设置组件属性

© Copyright 2011-2019 www.adophper.com. All Rights Reserved.
读图网科技 版权所有。蜀ICP备12031064号-1