2014-11-19 3 views
3

Мне просто интересно, есть ли у кого-нибудь идея о том, как реплицировать кнопку с плавающей кнопкой действия, для нового приложения Inbox для Android? У меня есть кнопки с плавающими действий рабочих (с кнопками подразделов), работающие с модифицированной версией этой библиотеки: https://github.com/futuresimple/android-floating-action-button/blob/master/README.mdКак реплицировать кнопку «Входящие» с плавающим действием (с текстом для каждой кнопки)?

Однако у меня возникают проблемы, пытаясь получить TextView рядом с кнопкой, как в приложении почтового ящика.

Если бы кто-то мог предложить мне предложение о том, как я собираюсь изменить библиотеку, чтобы принять это решение, или любой другой способ ее достижения, я бы очень признателен.

Спасибо за ваше время Corey

ответ

2

FloatinActionsMenu является ViewGroup он может принимать любой вид.

Создать макет как:

<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, получить его по идентификатору R.id.fab_expand_menu или .getChildAt(0), завернуть его, как вы программно бы сделать это в XML и установить его с помощью addView(0, wrapped)

Я планирую вилке, если случайно у меня есть время исправить это. Я отправлю ссылку на вилку.

6

Так Этикетки особенность FAB (как в Evernote или Входящие приложения) был добавлен в этот удивительный library чувствовать себя свободно использовать:

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> 

Наслаждайтесь!