开源库 FloatingActionButton

开源库FloatingActionButton

Github:https://github.com/Clans/FloatingActionButton

这个库是在前面这个库android-floating-action-button的基础上修改的,增加了一些更强大和实用的特性。

特性:

  • Android 5.0 以上点击会有水波纹效果

  • 可以选择自定义normal/pressed/ripple 的颜色

  • 可以选择设置FAB的阴影和阴影的大小

  • 可以选择取消标签和按钮的阴影

  • 可以自定义动画

  • 可以自定义Icon

  • 按钮支持56dp标准尺寸和40dp的mini尺寸

  • 可以自定义 FloatingActionMenu icon 动画

  • 菜单支持从上到下或者从下到上

  • 标签可以显示在左边或者右边

  • 可以为FloactinActionButton显示进度

  • 可以在代码中为FloatingActionMenu添加按钮

使用

grooy 复制代码
dependencies {
    compile 'com.github.clans:fab:1.6.4'
}

xml 中添加:

xml 复制代码
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 
    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
 
    <com.github.clans.fab.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        android:src="@drawable/ic_menu"
        fab:fab_colorNormal="@color/app_primary"
        fab:fab_colorPressed="@color/app_primary_pressed"
        fab:fab_colorRipple="@color/app_ripple"/>
 
</FrameLayout>

FloatingActionMenu 的一些自定义属性:

xml 复制代码
<com.github.clans.fab.FloatingActionMenu
        android:id="@+id/menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        fab:menu_fab_size="normal"
        fab:menu_showShadow="true"
        fab:menu_shadowColor="#66000000"
        fab:menu_shadowRadius="4dp"
        fab:menu_shadowXOffset="1dp"
        fab:menu_shadowYOffset="3dp"
        fab:menu_colorNormal="#DA4336"
        fab:menu_colorPressed="#E75043"
        fab:menu_colorRipple="#99FFFFFF"
        fab:menu_animationDelayPerItem="50"
        fab:menu_icon="@drawable/fab_add"
        fab:menu_buttonSpacing="0dp"
        fab:menu_labels_margin="0dp"
        fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
        fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
        fab:menu_labels_paddingTop="4dp"
        fab:menu_labels_paddingRight="8dp"
        fab:menu_labels_paddingBottom="4dp"
        fab:menu_labels_paddingLeft="8dp"
        fab:menu_labels_padding="8dp"
        fab:menu_labels_textColor="#FFFFFF"
        fab:menu_labels_textSize="14sp"
        fab:menu_labels_cornerRadius="3dp"
        fab:menu_labels_colorNormal="#333333"
        fab:menu_labels_colorPressed="#444444"
        fab:menu_labels_colorRipple="#66FFFFFF"
        fab:menu_labels_showShadow="true"
        fab:menu_labels_singleLine="false"
        fab:menu_labels_ellipsize="none"
        fab:menu_labels_maxLines="-1"
        fab:menu_labels_style="@style/YourCustomLabelsStyle"
        fab:menu_labels_position="left"
        fab:menu_openDirection="up"
        fab:menu_backgroundColor="@android:color/transparent"
        fab:menu_fab_label="your_label_here"
        fab:menu_fab_show_animation="@anim/my_show_animation"
        fab:menu_fab_hide_animation="@anim/my_hide_animation">
xml 复制代码
<com.github.clans.fab.FloatingActionButton
            android:id="@+id/menu_item"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_star"
            fab:fab_size="mini"
            fab:fab_label="Menu item 1" />
 
</com.github.clans.fab.FloatingActionMenu>

效果图:

相关推荐
csj5011 分钟前
安卓基础之《(14)—数据存储(4)应用组件Application》
android
李坤林39 分钟前
Android Binder 详解(6) Binder 客户端的创建
android·binder
北京自在科技40 分钟前
苹果iOS 26.3实现跨安卓数据无缝迁移
android·ios·findmy
_道隐_44 分钟前
Android里面的layer、DisplayList和hardwarebuffer之间是什么关系
android
stevenzqzq2 小时前
ctrl +B和ctrl+shift +B的区别
android·ide·android studio
似霰3 小时前
HIDL Hal 开发笔记5----Same-Process HALs 实例分析
android·framework·hal
robotx3 小时前
安卓16 设置壁纸中应用网格,有两个5X5的选项
android
Yyuanyuxin3 小时前
保姆级学习开发安卓手机软件(三)--安装模拟机并开始简单的进入开发
android·学习
Android小码家3 小时前
llama.cpp+Android应用定制
android·llama
龚礼鹏4 小时前
Android应用程序 c/c++ 崩溃排查流程二——AddressSanitizer工具使用
android·c语言·c++