Code B works well.
aHomeViewModel.isHaveRecord is LiveData<Boolean>, I hope to set different marginLeft based the value of aHomeViewModel.isHaveRecord .
Bur Code A get the following compile error, how can I fix it?
Cannot find a setter for <android.widget.TextView android:layout_marginLeft> that accepts parameter type 'float'
Code A
<TextView
android:id="@+id/title_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@{aHomeViewModel.isHaveRecord? @dimen/margin1: @dimen/margin2 }"
/>
<dimen name="margin1">10dp</dimen>
<dimen name="margin2">5dp</dimen>
Code B
<TextView
android:id="@+id/title_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin1"
/>
<dimen name="margin1">10dp</dimen>
<dimen name="margin2">5dp</dimen>
BTW, the following code can work well.
android:padding="@{aHomeViewModel.displayCheckBox? @dimen/margin1 : @dimen/margin2 }"