浮动操作按钮的低版本按钮、版本、操作

2023-09-03 23:27:14 作者:丢不掉的回忆//

有没有一种方法可以让我实现浮动按钮,在4.0及更高版本的Andr​​oid ??

Is there a way I can Achieve the floating button to work on 4.0 and later android??

我已经看到了它在谷歌加,但我还没有发现任何教程。仅适用于安卓升preVIEW。没有谷歌+用什么来实现呢?

I've seen it on google plus but I haven't found any tutorial. Only for android l preview. What did google+ use to achieve it?

推荐答案

您现在可以使用FloatingActionButton从支持设计库。加入这个依赖于你的摇篮构建文件:

You can now use the FloatingActionButton from the support-design library. Add this dependency to your gradle build file:

compile 'com.android.support:design:22.2.0'

然后添加FloatingActionButton到您的布局文件:

And then add the FloatingActionButton to your layout file:

 <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_done" />

例如,从克里斯·巴内斯项目:https://github.com/chrisbanes/cheesesquare.