【发布时间】:2022-03-23 19:35:33
【问题描述】:
我使用数据绑定来设置我的ImageView 的色调。这运作良好:
android:tint="@{plantEntity.isFavorite ? @color/favorite : @color/favorite_none}" />
问题是android:tint 已被弃用。当我尝试改用 app:tint 时,出现此错误:
Cannot find a setter for <android.widget.ImageView app:color> that accepts parameter type 'int' If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
为什么以及我必须做什么?创建BindingAdapter ?
【问题讨论】:
标签: android android-databinding