我想将视图的左侧和右侧限制为其父视图的边距,并使其填充分配的空间。但是,将宽度设置为match_parent
or wrap_content
似乎产生相同的结果。
是否有相当于 match_constraints 的东西(而不是 match_parent 和 wrap_content)?做match_parent
and wrap_content
影响布局还是在新的约束布局中忽略它们?
match_parent
不允许。但实际上您可以将宽度和高度设置为 0dp,并将顶部和底部或左侧和右侧约束设置为“parent”。
例如,如果你想拥有match_parent
限制元素的宽度,你可以这样做:
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)