简体   繁体   English

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

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

I have fragment with floating action button inside activity with collapsing toolbar. 我在活动中使用折叠工具栏时有带有浮动操作按钮的片段。 When toolbar is collapsed everything is ok, but when it's expended, FAB is not visible (it's below the screen). 当工具栏折叠时,一切正常,但在展开时,FAB不可见(它在屏幕下方)。 Here is xml of my fragment with 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>

replace 更换

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

with

android:layout_gravity="bottom|end"

This should work 这应该工作

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

相关问题 使用浮动操作菜单折叠工具栏 - Collapsing toolbar with floating action Menu 带有ViewPager和底部按钮的折叠工具栏 - Collapsing toolbar with viewpager and bottom button 始终将浮动动作按钮置于顶部 - Put the Floating action button on Top always 如何在浮动布局之类的主布局上方提升折叠工具栏? - How to elevate collapsing toolbar above main layout like the floating button? 折叠工具栏折叠时隐藏浮动按钮 - Hide floating button when collapsing toolbar is collapsed 如何使用浮动操作按钮创建底部导航 - How to create bottom navigation with floating action button 如何将浮动操作按钮对齐到结尾|底部 - How to align Floating Action Button to end|bottom 无法将浮动操作按钮放置在屏幕的右下方 - Cannot position floating action button to bottom right of the screen 底部导航栏浮动按钮,动作覆盖整个屏幕 - 如何做到这一点? - Bottom Navigation Bar Floating Button with action covering the whole screen - how to do this? 如何将浮动操作按钮放置在约束布局内的屏幕右下角? - How to place floating action button to right bottom of screen inside Constraint Layout?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM