With databinding we now often see codes in layout files like this:
<Variable name="displayIt" type="Boolean"/>
and then later:
android:visibility="@{displayIt ? View.VISIBLE : View.GONE}"
(of course android.view.View must first be imported for View.VISIBLE and View.GONE to have any meaning)
This makes controlling the view much easier. It also tells me that conditional statements are allowed in XML Layout, but it looks like my google-fu is weak, I tried and couldn't find the syntax for this. What if I want to use literals? Something like:
android:text="{@isValid ? "valid" : "invalid"}"
(yes I know that's a stupid way of doing it, I am just talking about the syntax here). Or what about resource ID's? Maybe like:
android:color="@{isValid ? R.color.green : R.color.red}"
Can it be done? What's the proper syntax?