Kotlin Anko自定义视图父范围
如果我们正在构建一个自定义视图,例如,如下所示:
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
?`扩展