android视图工具栏,android – 折叠折叠工具栏时隐藏浮动按钮

这篇博客讨论了如何在Android应用中,当折叠工具栏完全折叠时让浮动按钮消失,而在其他状态下保持可见。通过XML布局和属性设置,如`layout_scrollFlags`和`layout_anchor`,可以实现这一交互效果。问题中提供了包含折叠工具栏、嵌套滚动视图和浮动按钮的XML代码片段,但没有给出完整的解决方案。
摘要由CSDN通过智能技术生成

我有一个协调器布局,包含一个折叠工具栏,一个嵌套的滚动视图和一个浮动按钮.

我的浮动按钮位于折叠工具栏的右下端.我希望折叠工具栏完全折叠时按钮消失.在其他情况下可见.

我的xml:

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

tools:context="fr.djey.secretapp.MainActivity">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:theme="@style/AppTheme.AppBarOverlay"

android:id="@+id/appBar">

android:id="@+id/collapse_toolbar"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_scrollFlags="scroll|exitUntilCollapsed"

android:fitsSystemWindows="true"

app:contentScrim="?attr/colorPrimary"

app:expandedTitleMarginStart="48dp"

app:expandedTitleMarginEnd="64dp">

android:id="@+id/collapsing_image"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:fitsSystemWindows="true"

app:layout_collapseMode="parallax"

android:scaleType="centerCrop"

android:src="@drawable/welcome"/>

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

app:popupTheme="@style/ThemeOverlay.AppCompat.Light"

app:layout_collapseMode="pin"/>

android:layout_width="match_parent"

android:layout_height="match_parent"

xmlns:tools="http://schemas.android.com/tools"

android:layout_gravity="fill_vertical"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:id="@+id/content_frame">

android:id="@+id/fab"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginTop="-60dp"

android:layout_marginRight="16dp"

android:src="@android:drawable/ic_dialog_email"

app:layout_anchor="@id/collapse_toolbar"

app:layout_anchorGravity="bottom|right|end" />

有可能吗?怎么样?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值