繁体   English   中英

如何使用浮动工具栏将浮动操作按钮放置在屏幕底部,以使其始终可见

[英]How to put Floating Action Button in the bottom of the screen with Collapsing ToolBar to be always visible

我在活动中使用折叠工具栏时有带有浮动操作按钮的片段。 当工具栏折叠时,一切正常,但在展开时,FAB不可见(它在屏幕下方)。 这是我的FAB片段的xml:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/layout">


<ListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

</RelativeLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_anchor="@+id/layout"
    app:layout_anchorGravity="bottom|right|end"
    />


</android.support.design.widget.CoordinatorLayout>

更换

app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"

android:layout_gravity="bottom|end"

这应该工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM