使用FloatingActionButton无法浮现在ListView的原因

最近在项目中设计要求在主界面添加一个浮动按钮,第一时间就想到过最近比较火的FloatingActionButton,这里放上作者的github网址:点击打开链接

        然后在网上开始查资料..第一时间没有去作者的github的网址去查资料..教训啊..其实最好还是去作者的网站去查询如何使用,不过很遗憾当时并不知道这个design的作者.所以去网上搜索了一下.后来找到material design的一些用法..然而有一个问题没有解决..就是FloatingActionButton没办法浮动在Listview的上方,那还叫什么FLoating对不对!于是各种想办法解决..话说回来,没梯子真的挺累的,百度找这种问题没有办法...stackOverFlow还是挺有用的,然而还是没有解决问题...

最后找到作者的github网址,然后反复查看了好久~~注意到作者使用的是Framelayout而我是LinearLayout..严重怀疑是FrameLayout的缘故.然后搜了一下Framelayout毕竟学太久给忘了= =.然后知道Framelayout可以重复覆盖..然后问题就迎刃而解了..就是要把ListView和FloatingActionButton防止在同一个FrameLayout中,然后ListView的height属性不能设置为0.不然下面一片黑(因为是0就什么都没有,一片黑啊)...

放上改过之后正确的代码 :

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <ListView
        android:id="@+id/alarms_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:descendantFocusability="blocksDescendants"
        android:divider="#bbbbbb"
        android:dividerHeight="1dp" />
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.melnykov.fab.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_margin="0dp"
            android:src="@drawable/sign_add"
            fab:fab_type = "mini"
            fab:fab_colorNormal="@color/primary"
            fab:fab_colorPressed="@color/primary_pressed"
            fab:fab_colorRipple="@color/ripple"
            />
    </FrameLayout>
这里面的很多属性是不必要的....是我从自己的项目之中截取出来的..所以只要注意加上每个view的默认属性和上面所提到的一些细节就能够解决问题啦.

其实还是太弱= =,竟然一开始没看懂实现的细节!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值