I have a custom view that has a read
attribute, defined in xml like this:
<attr name="read" format="boolean" />
I get this attribute in the init
method of the custom view:
read = getBoolean(R.styleable.CustomCardView_read, true)
This sets the following property of the view:
var read: Boolean = false
set(value) {
field = value
card_read_stripe.visibility = if (value) View.GONE else View.VISIBLE
}
When I use this custom view I bind the read
property like this:
app:read="@{!object.fresh}"
My problem is that I always get true
from the styled attributes but never any value from the databinding side. The setter of read
is only called once with the default value of the attrs.xml attribute. The custom view also has some string attributes that are bound via databinding and those are implemented in the exact same way and they work without a problem. What could be the cause here?