【发布时间】:2017-07-04 12:07:16
【问题描述】:
我的应用中有一个FloatingActionButton,而不是RecyclerView。 Button 显示正常,但是当我单击它时,它下面的 RecyclerView 项目正在获取单击事件,而不是按钮。如果我将RecyclerView 设置为显示在FloatingActionButton 之上,Button 将按预期工作。
如何解决,让Button获取点击事件?
谢谢。
【问题讨论】:
-
将 FAB 放在相对布局或 LinearLayout 中,并将布局属性设置为 android:clickable="true" android:focusableInTouchMode="true" 并完成。
-
Fab.bringToFront() 并在 xml 中添加 clickable:true
-
如果您使用 android:clickable="false" android:enabled="false" android:focusableInTouchMode="false" 作为按钮,那么如果您在按钮上设置 OnClick 侦听器,它将需要单击。
标签: android android-recyclerview onclicklistener floating-action-button