Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton)【1】



Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton)【1】

由于FloatingActionButton在用户体验上取得了很好的效果,除了Android谷歌官方给出的原生FloatingActionButton之外,第三方也有很多FloatingActionButton的实现解决方案,比如github上的另外一个第三方开源FloatingActionButton项目主页:https://github.com/futuresimple/android-floating-action-button
该FloatingActionButton项目除了实现向Android谷歌官方实现的FloatingActionButton那样的效果外,还有一种特殊的动画效果,比如当用户点击一个FloatingActionButton时候,会弹出一长串FloatingActionButton等等,随后的文章中分节介绍如何具体使用。
先根据该开源FloatingActionButton项目写一个简单FloatingActionButton。

写一个简单的布局文件即可实现:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="zhangphil.fab.MainActivity" >

    <com.getbase.floatingactionbutton.FloatingActionButton
        android:id="@+id/pink_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        fab:fab_icon="@drawable/ic_launcher"
        fab:fab_colorNormal="@color/pink"
        fab:fab_colorPressed="@color/pink_pressed"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="16dp"/>

</RelativeLayout>


其颜色值在其项目的示例代码包中有定义(sample下的Activity中res/values/colors.xml):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="black_semi_transparent">#B2000000</color>
    <color name="background">#e5e5e5</color>
    <color name="half_black">#808080</color>
    <color name="white">#fafafa</color>
    <color name="white_pressed">#f1f1f1</color>
    <color name="pink">#e91e63</color>
    <color name="pink_pressed">#ec407a</color>
    <color name="blue_semi_transparent">#805677fc</color>
    <color name="blue_semi_transparent_pressed">#80738ffe</color>
</resources>


本例代码运行结果如图所示:


附录参考文章:
【1】《Android Material Design的FloatingActionButton,Snackbar和CoordinatorLayout》链接地址:http://blog.csdn.net/zhangphil/article/details/48861371
【2】《Android第三方FloatingActionButton:伴随ListView、RecyclerView、ScrollView滚动滑入滑出》链接地址:http://blog.csdn.net/zhangphil/article/details/50135707

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值