0

我在我的布局中使用材质 ImageView 并尝试使用数据绑定设置矢量可绘制我收到此错误

Cannot find a setter for <com.google.android.material.imageview.ShapeableImageView 
app:srcCompat> that accepts parameter type 'android.graphics.drawable.Drawable'

If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.

这是我的布局 XML

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<import type="android.graphics.drawable.Drawable" />

<variable
    name="icon"
    type="Drawable" />
<androidx.constraintlayout.widget.ConstraintLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content">

<com.google.android.material.imageview.ShapeableImageView
    android:id="@+id/iv_top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@{icon}"
     />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
4

0 回答 0