I followed the data binding documentation for Custom Binding Adapter for image loading from official Android Developers site: http://develo
Actually there are still some tutorials which add prefix to the BindingAdapter annotation.
@BindingAdapter({"imageUrl"}) without any prefix.
You will not get warning when using android: prefix in BindingAdapter. Because that is encouraged.
I will suggest to use @BindingAdapter("android:src") instead of creating a new attribute.
@BindingAdapter("android:src")
public static void setImageDrawable(ImageView view, Drawable drawable) {
view.setImageDrawable(drawable);
}
and
@BindingAdapter("android:src")
public static void setImageFromUrl(ImageView view, String url) {
// load image by glide, piccaso, that you use.
}
Create a new attribute only when you need it.