簡體   English   中英

如何復制收件箱浮動操作按鈕(每個子按鈕有文本)?

[英]How to replicate Inbox floating action button (with text for each sub button)?

我只是想知道是否有人知道如何復制新的收件箱應用程序為Android的浮動操作按鈕視圖? 我有浮動操作按鈕工作(帶子按鈕)使用此庫的修改版本: https//github.com/futuresimple/android-floating-action-button/blob/master/README.md

但是我在嘗試獲取按鈕旁邊的textview時遇到了麻煩,就像在收件箱應用程序中一樣。

如果有人能給我一個關於如何修改圖書館以適應這個或任何其他實現方式的建議,我將非常感激。

謝謝你的時間科里

由於標簽FAB功能(如在Evernote或Inbox應用程序中)被添加到這個很棒的庫中,可以隨意使用它:

Gradle依賴:

    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>

請享用!

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作為您的心臟欲望,背景,文本顏色等。

請注意,第一個FloatingActionButton將被移位到具有最大寬度的子視圖的大小。 您應該將其移動到最大子寬度 - 第一個浮動按鈕寬度。

如果你想將TextView也添加到那個FloatingAction中,可以通過id R.id.fab_expand_menu.getChildAt(0)來獲取它,像在xml中那樣以編程方式包裝它並使用addView(0, wrapped)設置它

我打算分叉,如果有機會我有時間修理它。 我將發布一個指向fork的鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM