【发布时间】:2020-06-03 18:26:53
【问题描述】:
我最近在尝试创建扩展 AndroidX 的 AppCompatImageView 的自定义类时遇到了异常。
android.view.InflateException:{package} 中的二进制 XML 文件第 9 行:layout/all_message_row:二进制 XML 文件行 // #9 in {package}:layout/all_message_row: Error inflating class {package}.ui.view.DotImageView
我在这个项目中使用了 View Binding,每当你给你的 View 充气时就会发生这种情况,比如:
AllMessageRowBinding.inflate(layoutInflater, parent, false)
这是类声明:
class DotImageView(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: androidx.appcompat.widget.AppCompatImageView(context, attrs, defStyleAttr) {
// rest of the class logic here
}
【问题讨论】:
标签: android kotlin exception imageview inflate-exception