5

I have found some resources about how to implement AND, less than and greater than operator in XML for Android data-binding.

& -> &

< -> &lt;

> -> &gt;

However, how to add OR operator? I cannot find the related information in Android official documentation.

I have visited these sites

StackOverflow --- android databinding using "&&" logical operator - Stack Overflow

StackOverflow --- android-databinding-using-logical-operator

Escape And(&&) Operator In Android Data Binding

My expected result:

<View
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="@{viewModel.fooBoolOne ||  viewModel.fooBoolTwo ? View.VISIBLE : View.GONE}"/>```
Myrick Chow
  • 332
  • 1
  • 6
  • 16

1 Answers1

3

You can use || operator in your xml without any changes.

Example :-

10 || 12
MohammedAli
  • 2,361
  • 2
  • 19
  • 36