4

我只是想知道是否有人知道如何复制新的 Inbox 应用程序为 android 提供的浮动操作按钮视图?我有浮动操作按钮(带有子按钮)使用这个库的修改版本: https ://github.com/futuresimple/android-floating-action-button/blob/master/README.md

但是,我在尝试获取按钮旁边的文本视图时遇到了麻烦,就像在收件箱应用程序中一样。

如果有人可以就我将如何修改库以适应这一点或任何其他实现它的方式向我提出建议,我将不胜感激。

谢谢你的时间科里

4

2 回答 2

7

由于标签 FAB 功能(如在 Evernote 或 Inbox 应用程序中)已添加到这个很棒的中,请随意使用它:

摇篮依赖:

    compile 'com.getbase:floatingactionbutton:1.3.0'

布局.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>

享受!

于 2014-12-08T10:24:20.663 回答
2

FloatinActionsMenuViewGroup不是可以接受任何观点。

创建布局,如:

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

风格TextView随心所欲、背景、文字颜色等。

请注意, firstFloatingActionButton将被替换为具有最大宽度的子视图的大小。您应该将其移动到最大的子宽度 - 第一个浮动按钮宽度。

如果您还想添加TextView到该 FloatingAction,请通过 id 获取它R.id.fab_expand_menu,或者.getChildAt(0),像在 xml 中那样以编程方式包装它并使用addView(0, wrapped)

我打算分叉,如果我有时间修复它。我会发布一个指向叉子的链接。

于 2014-11-25T19:05:37.473 回答