``` android:layout_marginRight="@{rankingItemViewM...
# android
c
Copy code
android:layout_marginRight="@{rankingItemViewModel.marginLeftOrRight ? 0: 100}"
Anyone can teach me what is wrong??….
stackoverflow 2
g
What is your problem exactly?
Probably different types
or marginLeftOrRight is not availabler
c
marginLeftOrRight is one of member of view model
compile fail…
g
and what is compile error?
j
missing the units?
g
maybe should be
rankingItemViewModel.marginLeftOrRight == null ? 0 : 100
or what is you check suppose to do
c
cannot find the setter for attribute ‘android:layout_marginRight’ with parameter type int on android.widget.ImageView
same error when i use code you wrote
g
try to use dimensions instead
100 -> 100dp
c
cant do that
I tried that but xml says no lol…
g
use @dimen/some_dimension
c
also I tried that…
xml says good, but occur same error code
I am so confused
Copy code
android:layout_gravity="@{rankingItemViewModel.marginLeftOrRight ? Gravity.RIGHT : Gravity.LEFT, default = right}
Copy code
android:visibility="@{rankingItemViewModel.detailVisivility ? View.VISIBLE : View.GONE, default = gone}"
first one is not working but, second one is working
g
I would just use custom binding adapter
c
hum… anyways Thanks !!
g
Also, if first one doesn’t work, why not just use
default = Gravity.RIGHT
instead