FloatingActionButton的使用
本例中显示在下方中间的FAB,可以直接当初Imagebutton来使用
android:id="@+id/id_fab_toSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/icon_to_send"
app:backgroundTint="@color/main_color"
app:borderWidth="0dp"
android:layout_marginBottom="@dimen/fab_margin">
app:backgroundTint="@color/main_color"为FloatingActionButton正常显示的情况下有个填充的颜色,有个阴影;
app:rippleColor="#33728dff" 为ripple的color
和立体感相关有两个属性,elevation和pressedTranslationZ,前者用户设置正常显示的阴影大小;后者是点击时显示的阴影大小。大家可以自己设置尝试下。
综上,如果你希望自定义颜色、以及阴影大小,可以按照如下的方式(当然,颜色你也可以在theme中设置):
app:backgroundTint="#ff87ffeb"
app:rippleColor="#33728dff"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
查看全部