Android约束布局-儿童对齐
因此,我有一个约束布局,高度Android约束布局-儿童对齐,android,constraints,Android,Constraints,因此,我有一个约束布局,高度wrap\u content和宽度match\u parent。我想知道 如何将按钮与回收器视图的中心对齐(如果它们是水平渲染的) 如何将按钮与线性布局的中心对齐(稍后将填充)。。如果它们是水平渲染的 我尝试了constraint.Guideline,但由于约束布局wrap\u内容高度,它似乎不起作用。有什么建议吗?要居中对齐,需要设置相对于父对象的左对齐和右对齐。e、 g <Button android:id="@+id/button" app
wrap\u content
和宽度match\u parent
。我想知道
按钮
与回收器视图
的中心对齐(如果它们是水平渲染的)按钮
与线性布局
的中心对齐(稍后将填充)。。如果它们是水平渲染的我尝试了
constraint.Guideline
,但由于约束布局wrap\u内容
高度,它似乎不起作用。有什么建议吗?要居中对齐,需要设置相对于父对象的左对齐和右对齐。e、 g
<Button
android:id="@+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
也许这个答案对其他人有用 我们可以在回收器视图或线性布局下方有一个空视图
<View
android:id="@+id/horizontal_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyclerview"
tools:layout_editor_absoluteX="8dp" />
这应该可以完成以下工作:)得到第一种情况的结果,但在第二种情况下没有结果(线性布局),它有固定的高度
app:layout_constraintBottom_toTopOf="@+id/horizontal_view"
app:layout_constraintLeft_toLeftOf="@+id/parent"
app:layout_constraintRight_toLeftOf="recyclerview"
app:layout_constraintTop_toTopOf="parent"