Closed vlytvyne closed 4 years ago
The easiest workaround I found is to create my own BindingAdapter:
@BindingAdapter("lineColor") fun PinView.setLineColor(@ColorRes id: Int) { this.setLineColor( ResourcesCompat.getColorStateList(resources, id, null)) }
Then you can use data binding as follows:
app:lineColor="@{viewmodel.isError ? R.color.error : R.color.selector_pin_view }"
I'm trying to do something like this:
app:lineColor="@{viewmodel.isError ? @drawable/selector_pin_view_error : @drawable/selector_pin_view}"
but there is no setter for attribute "app:lineColor" with parameter type Drawable. Worth mentioning that databinding does work with colors, like this:app:lineColor="@{viewmodel.isError ? @color/error : @color/default}"