How do I replicate an Inbox button with an active action (with text for each button)?
I'm just wondering if anyone has an idea on how to replicate the floating action button for the new Inbox Android app? I have floating action buttons working (with extra buttons) working with a modified version of this library: https://github.com/futuresimple/android-floating-action-button/blob/master/README.md
However, I am having trouble trying to get a text image next to a button, for example in the Inbox application.
If someone can offer me a suggestion on how I am going to modify the library to make this decision, or any other way to achieve it, I would greatly appreciate it.
Thanks for your time Corey
source to share
Since the FAB shortcuts feature (like in Evernote or Inbox apps) has been added to this awesome library , feel free to use it:
Gradle dependency:
compile 'com.getbase:floatingactionbutton:1.3.0'
layout.xml:
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
fab:fab_addButtonColorNormal="@color/white"
fab:fab_addButtonColorPressed="@color/white_pressed"
fab:fab_addButtonPlusIconColor="@color/half_black"
fab:fab_labelStyle="@style/menu_labels_style"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="Action A"
fab:fab_colorPressed="@color/white_pressed"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="Action B"
fab:fab_colorPressed="@color/white_pressed"/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
menu_labels_style.xml:
<style name="menu_labels_style">
<item name="android:background">@drawable/fab_label_background</item>
<item name="android:textColor">@color/white</item>
</style>
fab_label_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_semi_transparent"/>
<padding
android:left="16dp"
android:top="4dp"
android:right="16dp"
android:bottom="4dp"/>
<corners
android:radius="2dp"/>
</shape>
Enjoy!
source to share
FloatinActionsMenu
ViewGroup
he can accept any representation.
Create a layout like:
<FloatingActionsMenu
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<RelativeView
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/floating_description_1"/>
<FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
//....
</RelativeLayout>
<RelativeView
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/floating_description_2"/>
<FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
//....
</RelativeLayout>
</FloatingActionsMenu>
Style TextView
as you wish, background, text color, etc.
Note that the first one FloatingActionButton
will be offset by the size of the child's view with the largest width. You have to wrap it to the larger child width - the first width of the floating button.
If you want to add TextView
to this plagiarized window as well, get it with id R.id.fab_expand_menu
or .getChildAt(0)
, wrap it programmatically as you would in xml and set it withaddView(0, wrapped)
I plan to fork if by chance I have time to fix it. I'll post a link to the fork.
source to share