例如,如果我们正在构建一个自定义视图,如下所示:
class FrameLayoutNormal: FrameLayout{
constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
textView{
lparams(...)
}
}
我们不能定义 lparams,因为编译器不知道父级是谁。如果我们将 textView 包装在 FrameLayout 中,它就可以工作,并且您可以指定布局参数。但是在自定义视图中,父级就是它自己。那么我们如何让孩子们意识到这一点,以便我们可以使用扩展程序呢?
除了从以下位置扩展之外,还有什么方法可以让它工作_FrameLayout
?