I tried this, and it works for me (buildToolsVersion: 24.0.1):
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="8dp"
android:scaleType="centerInside"
app:imageResource="@{item.avatarResId}"/>
just use app:imageResource
to replace android:src
, android:src="@{item.avatarResId}"
doesn't works else define a custom @BindAdapter("android:src")
for it.
but use app:imageResource
doesn't need define a @BindAdapter
additionally, because the ImageView has a method called setImageResource()
, when you use app:imageResource
, it will call setImageResource()
automatically.