Floating key shortcut

Is it possible to show the label (for example enter image description here) of a button of a floating action without using a third-party library? I am using the Android support library for my factory, and I want to know if I can show a shortcut with it.

My code for FAB is as follows:

    <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 do not use any menu only FAB.

+4
source share
4 answers

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>
+6
source

You can use the code below:

<RelativeLayout 
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >

<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="#00fff0"
app:borderWidth="0dp"
android:elevation="0dp"
app:fabSize="normal" />

<TextView
android:layout_toRightOf="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="Compose"/>

</RelativeLayout>
+1
source

Try it

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:padding="@dimen/padding_4"
        android:text="Add"
        android:textColor="@android:color/black" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_scan"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="@dimen/margin_16"
        android:layout_marginLeft="@dimen/margin_16"
        android:layout_marginRight="@dimen/margin_16"
        android:layout_marginTop="@dimen/margin_8"
        android:src="@android:drawable/ic_input_add" />

</LinearLayout>
+1
source

You really want to use FloatingActionMenu.

Example:

<android.support.design.widget.FloatingActionMenu
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end">

    <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"
        app:fab_label="fab_visitdetail_label"
        android:src="@drawable/right_arrow"/>
</android.support.design.widget.FloatingActionMenu>
0
source

Source: https://habr.com/ru/post/1686199/


All Articles