FloatActionButton的一些认识
FloatActionButton是ImageButton的继承类,其用法跟普通的Button基本类似,由于其具有更多的表现属性,故其使用的重点其实是在布局上。
<
android.support.design.widget.FloatingActionButton
android :id= "@+id/fab"
android :layout_width= "wrap_content"
android :layout_height= "wrap_content"
android :layout_gravity= "bottom|end"
android :layout_margin= "@dimen/fab_margin"
android :id= "@+id/fab"
android :layout_width= "wrap_content"
android :layout_height= "wrap_content"
android :layout_gravity= "bottom|end"
android :layout_margin= "@dimen/fab_margin"
android:src="@mipmap/butterfly" //图片
app:backgroundTint="#440000"//设置普通状态颜色
app
:rippleColor=
"#00ff00" //设置按下的颜色
app:fabSize="normal"/>
可以指定两个大小通过设置fabSize这个属性,正常size是normal,还有一个更小的模式为mini
FloatActinButton最大的特点是其悬浮的效果,所以关于其立体感的属性当然也重要。这里也是要涉及两个属性: elevation和pressedTranslationZ,分别为普通状态下的阴影大小和点击时阴影的大小(本人做实验没发现啥变化)
android
:
elevation
=
"15dp"
app :pressedTranslationZ= "20dp"
app :pressedTranslationZ= "20dp"