使用目标:
悬浮按钮,悬浮于RecyclerList之上,并位于屏幕右下。
问题:
网上的中文介绍没有提及如何真正悬浮,而只是尝试了最简单的Demo。
所谓的悬浮效果,其实就是使用该控件,google自带的阴影和立体效果而已。
解决办法:
原因:
You should use RelativeLayout, and as we know, later children in a RelativeLayout tend to float over earlier children in a RelativeLayout.
So, to have a FAB float over of any layout, make sure that the FAB is defined after all views (at the end of the XML layout).
也就是说,RelativeLayout定义在后面的子控件,如果和之前的控件位置重叠了的话,就会覆盖在之前的控件上面。所以如果想要使用FAB悬浮在其他控件上的话,要确保最后定义FAB
教训:
1、之前我一直用最容易理解的LinearLayout,因为不需要使用其他的Root-layout。但是现在可以开始向下学习root-layout的不同方式了。
2、StackOverFlow是个好东西,在google上多使用英文搜索,更容易找到答案