I need to be able to dynamically set an EditText\'s height property. I am using data binding for other properties throughout my app, so I would love to be able to use data b
In Java
@BindingAdapter("layout_height")
public static void setLayoutHeight(View view, float height) {
LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = height;
view.setLayoutParams(layoutParams);
}
And in your XML
app:layout_height="@{ viewModel.isBig ? @dimen/dp_20 : @dimen/dp_5 }"
import the app like this
xmlns:app="http://schemas.android.com/apk/res-auto"