所以我有一个高度为wrap_content且宽度为match_parent的约束布局。我想知道


如果button水平呈现,如何将recycler view对准button的中心。
如何将LinearLayoutconstraint.Guideline的中心对齐(稍后将填充)..如果它们是水平渲染的。


我尝试了wrap_content,但由于约束布局高度而似乎无法正常工作。有什么建议么?

最佳答案

也许对于其他人来说,这个答案可能是有用的。

在回收者视图或线性布局下面,我们可以有一个空白视图。

<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"


这应该做的工作:)

关于android - Android约束布局- child 对齐,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46213359/

10-12 00:23
查看更多