有没有标准的工具或现有的库可以创建类似于Gmail应用程序上的圆形按钮?
![enter image description here](https://istack.dev59.com/shnoQ.webp)
compile 'com.android.support:design:22.2.0'
<RelativeLayout
...
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.FloatingActionButton
android:id="@+id/myFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/ic_discuss"
android:layout_margin="10dp"
android:clickable="true"/>
</RelativeLayout>
Android设计支持库的详细信息请 参见此处
此外,还有许多其他提供FAB的库,例如:
1.首要使用Android Studio
2.将以下内容添加为依赖项到你的build.gradle文件中:
dependencies {
compile 'com.melnykov:floatingactionbutton:1.3.0'
}
3. 创建布局
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_action_content_new"
fab:fab_colorNormal="@color/primary"
fab:fab_colorPressed="@color/primary_pressed"
fab:fab_colorRipple="@color/ripple" />
4. 添加命名空间
xmlns:fab="http://schemas.android.com/apk/res-auto"
将以下代码添加到您的布局文件中:
fab:fab_type="mini"
或者
fab.setType(FloatingActionButton.TYPE_MINI);