【问题标题】:Using coordinatorLayout anchor's with constraintLayout将 coordinatorLayout 锚点与约束布局一起使用
【发布时间】:2023-03-08 12:14:01
【问题描述】:

我想设计这样的东西:

如您所见,fab 位于 header 和 body 之间。

使用带有app:anchor 和app:anchorGravity 属性的coordinatorLayout 很容易做到

但我想用 constraintLayout 来做。

有什么想法吗?

【问题讨论】:

    标签: android android-layout android-coordinatorlayout android-constraintlayout


    【解决方案1】:

    我找到了答案:))

    <FAB
       ...
       app:layout_constraintTop_toBottomOf="@+id/header"
       app:layout_constraintBottom_toTopOf="@id/body"/>
    

    【讨论】:

    • 这样,您只是定位 FAB,但如果您想使用材料设计动画,您应该使用 CoordinatorLayout 作为您的父级,例如视差。
    • 是的,你是对的,但我只需要将工厂定位在这两种布局之间。
    • 能发一下角色代码吗?我对此有疑问......我的“标题”放在fab按钮前面
    • @FelipeA。您需要将您的 FAB xml 标签移动到其他标签(标题和正文)下方
    猜你喜欢
    • 2017-08-08
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多