Android5.0 FloatingActionButton使用小结

FloatingActionButton, 这是一个浮动按钮。

1.导入包
compile 'com.android.support:design:22.2.0'
2.常用属性介绍
  1. app:backgroundTint - 设置FAB的背景颜色。
  2. app:rippleColor - 设置FAB点击时的背景颜色。
  3. app:borderWidth -该属性尤为重要,如果不设置0dp,那么在4.1的sdk上FAB会显示为正方形,而且在5.0以后的sdk没有阴影效果。所以设置为borderWidth=”0dp”。
  4. app:elevation - 默认状态下FAB的阴影大小。
  5. app:pressedTranslationZ - 点击时候FAB的阴影大小。
  6. app:fabSize - 设置FAB的大小,该属性有两个值,分别为normal和mini,对应的FAB大小分别为56dp和40dp。
  7. src - 设置FAB的图标,Google建议符合Design设计的该图标大小为24dp。
  8. app:layout_anchor - 设置FAB的锚点,即以哪个控件为参照点设置位置。
  9. app:layout_anchorGravity - 设置FAB相对锚点的位置,值有
    bottom、center、right、left、top等。
3.示例
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floatActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher"
        app:backgroundTint="#eeeeee"
        app:elevation="2dp"
        app:fabSize="normal" />
</LinearLayout>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值