Search code examples
androidfloating-action-button

Floating action button's label


Is it possible to show the label (like this enter image description here) of floating action button without using any third party library? I am using android support library for my fab and I want to know if I can show a label with it.

My code for FAB looks like this:

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_visitdetail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        android:src="@drawable/right_arrow"/>

I'm not using any menu just a FAB.


Solution

  • try something like this

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right">
    
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_visitdetail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="16dp"
            android:src="@drawable/right_arrow"/>
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Compose"
            android:elevation="16dp"
            android:textColor="@android:color/white"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </FrameLayout>