android – 滚动感知FAB隐藏,但后来不再出现

android – 滚动感知FAB隐藏,但后来不再出现,第1张

概述我制作了一个带有recyclerview和浮动动作按钮的 Android应用程序.向下滚动时,按钮应隐藏,向上滚动时应再次显示.我用 this tutorial来实现这个行为. 结果是,当我向下滚动时FAB隐藏,但是当向上滚动时它不会再次出现:(类ScrollAwareFABBehavior与教程相同.但我使用的是嵌套布局. 这是我的布局(recyclerview位于content_main的Li 我制作了一个带有recyclervIEw和浮动动作按钮的 Android应用程序.向下滚动时,按钮应隐藏,向上滚动时应再次显示.我用 this tutorial来实现这个行为.

结果是,当我向下滚动时FAB隐藏,但是当向上滚动时它不会再次出现:(类ScrollAwareFABBehavior与教程相同.但我使用的是嵌套布局.

这是我的布局(recyclervIEw位于content_main的linearLayout中):

<androID.support.design.Widget.CoordinatorLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    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="org.myorganisation.mypackage.someActivity">    <include layout="@layout/toolbar" />    <include layout="@layout/content_main" />    <androID.support.design.Widget.floatingActionbutton        androID:ID="@+ID/add_fab"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_gravity="bottom|end"        androID:layout_margin="@dimen/fab_margin"        androID:src="@drawable/plus"        app:layout_behavior="org.myorganisation.mypackage.someActivity.helpers.ScrollAwareFABBehavior" />    <linearLayout        androID:ID="@+ID/insert_alert"        androID:layout_wIDth="wrap_content"        androID:layout_height="50sp"        androID:layout_margin="@dimen/fab_margin"        androID:gravity="center_vertical"        androID:orIEntation="horizontal"        androID:paddingEnd="70sp"        androID:visibility="gone"        app:layout_anchor="@ID/add_fab"        app:layout_anchorGravity="bottom|left">        <TextVIEw            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:gravity="center_vertical"            androID:text="@string/initial_alert"            androID:textcolor="@color/colorPrimaryDark"            androID:textStyle="bold|italic" />        <ImageVIEw            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:src="@drawable/ic_keyboard_arrow_right_black_24sp"            androID:tint="@color/colorPrimary" />    </linearLayout></androID.support.design.Widget.CoordinatorLayout>
解决方法 从支持库的25.1.0版开始,隐藏视图不再按照 this bug滚动事件.

如comment #5所述:

This is working as intended,your dependency chain is the wrong way. Your RecyclerVIEw (Behavior) should be triggering the FAB visibility change.

总结

以上是内存溢出为你收集整理的android – 滚动感知FAB隐藏,但后来不再出现全部内容,希望文章能够帮你解决android – 滚动感知FAB隐藏,但后来不再出现所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1138404.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存