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

更多相关文章

  1. Android之WebView控件简单使用总结
  2. Android动画(一)Interpolator
  3. Android(安卓)SlidingMenu实现沉浸式状态栏
  4. Android软件盘(EditText)的搜索功能
  5. Android(安卓)requires compiler compliance level 5.0 or 6.0.
  6. Android(安卓)获取照相机图片或本地图片
  7. Cocos2d-x + Android(安卓)+ Eclipse + Windows 8
  8. Android(安卓)视频和音频采集
  9. Android_开发 实用滚轮效果选择数字(十三)

随机推荐

  1. Android(安卓)Menu学习
  2. 自定义View系列教程07--详解ViewGroup分
  3. android调用第三方软件打开下载的附件
  4. android桌面快捷方式添加数字角标的踩坑
  5. Cortex-A8和Android应用开发视频教程
  6. Android中如何像 360 一样优雅的杀死后台
  7. 系出名门 Android(安卓)系列文章索引
  8. Android(安卓)XML解析技术
  9. Android(安卓)Matrix矩阵详解
  10. Android(安卓)RoboGuice 使用指南(13):Ro