在Java中
@BindingAdapter("layout_height")public static void setLayoutHeight(View view, float height) { LayoutParams layoutParams = view.getLayoutParams(); layoutParams.height = height; view.setLayoutParams(layoutParams);}在您的XML中
app:layout_height="@{ viewModel.isBig ? @dimen/dp_20 : @dimen/dp_5 }"像这样导入应用
xmlns:app="http://schemas.android.com/apk/res-auto"



