In viewModel i had a function like this:
fun getTextInputStyle(): Int {
val style = if (isTrue) {
R.style.styleOne
} else {
R.style.styleTwo
}
return style
}
In XML file there is a textInputLayout call the function from ViewModel:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_first_name"
style="@{viewModel.getTextInputStyle}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_16sdp"
android:layout_marginTop="@dimen/_13sdp"
android:layout_marginEnd="@dimen/_16sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rg_title">
</com.google.android.material.textfield.TextInputLayout>
And here the error logged in the console:
Cannot find a setter for
<com.google.android.material.textfield.TextInputLayout style>
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.