简体   繁体   中英

How can i create a different shape floating action button

I am trying to get a floating action button but in a different size, I have tried some links but none of them worked. Any help would be great

I have tried code and I was tried to take an image view above bottom navigation view. But after clicking on the fragment, it was disappeared.

在此处输入图片说明

 <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" />

I am trying to make a fab with oval shape

Below is workign code

oval.xml (shape)

<?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>

Let me know for more help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM