首页 > 解决方案 > 如何创建不同形状的浮动操作按钮

问题描述

我正在尝试获得一个浮动操作按钮,但大小不同,我尝试了一些链接,但没有一个有效。任何帮助都会很棒

我尝试了代码,并尝试在底部导航视图上方拍摄图像视图。但是点击片段后,它就消失了。

在此处输入图像描述

 <com.jediburrell.customfab.FloatingActionButton
        android:id="@+id/floating_action_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        app:fabType="custom"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        app:fabShape="@drawable/fab_teardrop"
        app:fabColor="@color/red" />

我正在尝试制作椭圆形的晶圆厂

标签: androidfloating-action-button

解决方案


下面是工作代码

椭圆形.xml(形状)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid android:color="@color/colorPrimary" />


</shape>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:layout_width="82dp"
        android:layout_height="65dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_margin="16dp"
        android:background="@drawable/oval"
        android:src="@android:drawable/ic_dialog_map"
        app:backgroundTint="@drawable/oval" />
</RelativeLayout>

让我知道以获得更多帮助


推荐阅读