Android Design Support Library

为什么80%的码农都做不了架构师?>>>
关于使用
其实我相信很多人都用过了 控件了 , 但是还是要说一下 , 毕竟有些人接触的晚一些 , 一些人接触的早一些 , 先从最简单的使用看起:
【Android Design Support Library】属性值作用
app:
设置FAB未按下时的景深
app:
设置FAB按下时的景深
app:
设置FAB的大小 , 默认只有和mini两种选项
app:
设置FAB的边框宽度
:src
设置FAB的
app:
设置FAB按下时的背景色
app:
设置FAB未按下时的背景色
app:
设置FAB的锚点
app:
设置FAB相对于锚点的位置
app:
设置FAB的行为属性
大部分的属性还是很好理解的 , 这里要提一下几个注意的点
中的 FAB:

Android Design Support Library

文章插图
中的 FAB
中的 FAB:
Android Design Support Library

文章插图
中的 FAB
很容易看出 ,  中存在边缘显示的问题 。为了解决此问题 , API21+ 的版本统一定义底部与右边缘空白为 16dp ,  以下版本统一设置为 0dp.解决办法:
/.xml
0dp0dp
-v21/.xml
16dp16dp
布局文件的 FAB 中 , 也设置相应的值:

以上这段话出处
最简单的使用

Android Design Support Library

文章插图
最简单的使用
更酷炫的效果

Android Design Support Library

文章插图
更酷炫的效果
这张图片出处
可以看出我们只要使用app:属性设置一个控件作为FAB的锚 , 然后通过app: 属性放置FAB在这个相对的锚的位置 , 就能做出你想要的效果 。
自定义
如果你还记得这张图的话:
Android Design Support Library

文章插图
交互效果
或者说你见过这种交互效果:
Android Design Support Library

文章插图
交互效果
其实这些都是通过这个类做出来的 , 以上的两种动画都是默认自带的 , 在 内部有对类的描述:
/*** Interaction behavior plugin for child views of {@link CoordinatorLayout}.** A Behavior implements one or more interactions that a user can take on a child view.* These interactions may include drags, swipes, flings, or any other gestures.
** @param The View type that this Behavior operates on*/public static abstract class Behavior {

可以看到这是一个抽象类 , 我们可以在各个 去实现这个类 , 这里提到FAB , 我们可以找一下FAB中的默认交互的实现:
/*** Behavior designed for use with {@link FloatingActionButton} instances. It's main function* is to move {@link FloatingActionButton} views so that any displayed {@link Snackbar}s do* not cover them.*/public static class Behavior extends CoordinatorLayout.Behavior {// We only support the FAB <> Snackbar shift movement on Honeycomb and above. This is// because we can use view translation properties which greatly simplifies the code.private static final boolean SNACKBAR_BEHAVIOR_ENABLED = Build.VERSION.SDK_INT >= 11;