无法使用数据绑定设置图像视图的背景

Not able to set background of imageview using databinding

我正在尝试在我的 recyclerview 中设置 imageview 的背景,但它没有显示任何内容,只有空 space 图像,当我使用占位符图像时,它显示占位符图像而不是图像 URL我想在图像视图中显示

我的代码

@BindingAdapter("imageName")
fun setImageFromURls(view: ImageView, fileName: String) {
    Glide.with(view.context)
            .load(fileName)
            .into(view)
}

回收者视图

 <com.google.android.material.imageview.ShapeableImageView
            android:id="@+id/roundedImageView"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:adjustViewBounds="true"
            app:imageName="@{productitem.image}"
            android:scaleType="fitXY"
            app:shapeAppearanceOverlay="@style/roundimageview" />

产品

@Parcelize
data class Product(

        val image: String
        ):Parcelable

数据提供者

object DataProvider {

    val productList: MutableList<Product> = ArrayList()

    private fun addProduct(imageUri: String) {

        val item = Product(imageUri)
        productList.add(item)


    }
    init {
        addProduct("https://images.unsplash.com/photo-1598128558393-70ff21433be0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1922&q=80")
        addProduct("https://images.unsplash.com/photo-1598128558393-70ff21433be0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1922&q=80")
        addProduct("https://images.unsplash.com/photo-1581090700227-1e37b190418e?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80")
        addProduct("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1050&q=80")
        addProduct("https://images.unsplash.com/photo-1473968512647-3e447244af8f?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80")

    }
}
@BindingAdapter("imageName")
fun setImageFromURls(view: @BindingAdapter("imageName")
fun setImageFromURls(view: ShapeableImageView, fileName: String) {
    Glide.with(view.context)
            .load(fileName)
            .into(view)
}

使用 ShapeableImageView 代替 ImageView 解决了我的问题