开源库 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>

效果图:

相关推荐
三少爷的鞋6 小时前
从 MVVM 到 MVI:为什么说 MVVM 的 UI 状态像“网”,而 MVI 像“一条线”?
android
蜡台7 小时前
Flutter 安装配置
android·java·flutter·环境变量
阿乐艾官7 小时前
【HBase列式存储数据库】
android·数据库·hbase
yoyo_zzm9 小时前
MySQL的索引
android·数据库·mysql
Okailon9 小时前
PHP面向对象模块 jc-simple-footer 的技术详解
android·php·开源软件·家谱软件
llxxyy卢10 小时前
polar-web部分中等题目
android·前端·sql·web安全
zJianFlys11 小时前
Android16(API36)在获取WiFi信息时SSID为<unknown ssid>
android
WarPigs11 小时前
Android开发笔记
android
星河耀银海12 小时前
C++ 异常处理机制:异常捕获、自定义异常与实战应用
android·java·c++
AndroidCode12 小时前
Android Automotive Power Policy 全流程技术解析
android