如何selectableButtonBackground
在自定义视图上使用属性,该视图apply()
在其构造函数中使用 Anko 的方法,如下面的结构?
class XPTO(context: Context) : CardView(context) {
init {
this.apply {
// I'd like to invoke selectableButtonBackground here
}
}
我试过做,context.obtainStyledAttributes(arrayOf(R.attr.selectableItemBackground).toIntArray()).getDrawable(0)
但没有成功。