ConstraintLayout中,如何转换xml属性:
app:layout_constrainedWidth=”true|false”
in code?
如果你想设置constrainedWidth/Height
以编程方式,那么你必须采取ConstraintLayout.LayoutParams
供您查看并设置名为约束宽度 or 约束高度随你的意愿。
I.e.
ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) myView.getLayoutParams(); // View for which we need to set constrainedWidth.
lp.constrainedWidth = true/false;
myView.setLayoutParams(lp);
约束宽度
指定在左侧和右侧的情况下水平尺寸是否受到约束
设置了正确的约束并且小部件尺寸不是固定的
方面。
默认情况下,如果小部件设置为WRAP_CONTENT
, 我们将
将该维度视为固定尺寸,这意味着维度将
无论约束如何都不会改变。
将此属性设置为true允许尺寸改变以遵守约束。
查看here https://developer.android.com/reference/android/support/constraint/ConstraintLayout.LayoutParams.html#constrainedwidth.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)