Google最近为了让开发者更好的更规范的应用Material Design设计思想,特意放出了android support design library,里面含有更多Material Design的标志性组件,其中最常用的就是那个圆形按钮,叫做Floating Action Button,可以简称为FAB。
举个栗子
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:borderWidth="0dp"
app:rippleColor="@color/mainColor"
app:backgroundTint="@color/mainColor"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:src="@drawable/plus"
/>
注释:
- app:borderWidth="0dp" 解决在5.x的设备上运行,木有阴影的问题
- app:backgroundTint="@color/mainColor" 配置未点击时的按钮颜色
- app:rippleColor="@color/mainColor" 配置点击时的样式
- app:elevation="6dp" 配置未点击时的阴影大小
- app:pressedTranslationZ="12dp" 配置点击时的阴影大小
- android:src="@drawable/plus" 按钮内部图片
待研究问题
- 在布局浏览器中显示的位置与手机中的位置不同,总有边距,不知该怎么去除。