Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton)【1】
2015-12-03 21:44
393 查看
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
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
相关文章推荐
- Android设置特定时间执行操作
- Android SurfaceView简介
- 短信发送器
- Android电话拨号器
- Intent的简介以及属性的详解
- Android SharedPreferences安全存储/AutoCompleteTextView使用/文件读写
- Activity的生命周期
- Android 手势控制解锁,滑动图片,照相,音乐切换,收音机换台,短信界面打电话
- Android作业分组与选题
- 用Intent调用系统中经常被用到的组件
- Android是否联网判断
- 设置ExpandableListView不显示分割线
- float/double数据不显示成科学计数法
- Android关于ListView的分割线问题
- Android 让EditText输入框失去焦点
- android修改控件外观(使用drawable资源)
- Android之发送短信后按钮(60秒)变灰色每隔一秒递减显示
- Android Fragment应用实战,使用碎片向ActivityGroup说再见
- android有关图片的操作(一)
- Android 修改当前显示时间