简体   繁体   English

如何集成可扩展的浮动操作按钮

[英]How to integrate an expandable Floating Action Button

I am a beginner in android development using Java, I have tried surfing the net but to no avail.我是使用 Java 进行 android 开发的初学者,我尝试过上网但无济于事。 What is name of the library which I can use to make expandable Floating Action Button like the one on the pic below.我可以用来制作可扩展的浮动操作按钮的库的名称是什么,如下图所示。
Please help.请帮忙。

图片

I was looking at some source codes.我在看一些源代码。 I found a best expandable FAB(Float Action Button)我找到了一个最好的可扩展 FAB(浮动操作按钮)

Let me add those source codes.让我添加这些源代码。 Add it to build.gradle添加到 build.gradle

implementation 'com.nambimobile.widgets:expandable-fab:1.0.2'

Add following source code to layout将以下源代码添加到布局

<!-- This is NOT a root view, but should be a child of whatever root view you 

choose (CoordinatorLayout, ConstraintLayout, etc) -->
<com.nambimobile.widgets.efab.ExpandableFabLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent">
  
  <!-- The next 3 Views will only display in portrait orientation -->          
  <com.nambimobile.widgets.efab.Overlay
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:overlay_orientation="portrait"/>
  <com.nambimobile.widgets.efab.ExpandableFab
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginBottom="@dimen/ui_margin_medium"
    android:layout_marginEnd="@dimen/ui_margin_medium"
    android:layout_marginRight="@dimen/ui_margin_medium"
    app:efab_orientation="portrait"/>
  <com.nambimobile.widgets.efab.FabOption
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:fab_orientation="portrait"
    app:label_text="Portrait Option 1"
    android:onClick="onClickPortraitOption1"/>

  <!-- The next 3 Views will only display in landscape orientation -->
  <com.nambimobile.widgets.efab.Overlay
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:overlay_orientation="landscape"/>
  <com.nambimobile.widgets.efab.ExpandableFab
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginBottom="@dimen/ui_margin_medium"
    android:layout_marginEnd="@dimen/ui_margin_medium"
    android:layout_marginRight="@dimen/ui_margin_medium"
    app:efab_orientation="landscape"/>
  <com.nambimobile.widgets.efab.FabOption
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:fab_orientation="landscape"
    app:label_text="Landscape Option 1"
    android:onClick="onClickLandscapeOption1"/>
            
</com.nambimobile.widgets.efab.ExpandableFabLayout>

Then, you can use those FAB as you use on button in Java file.然后,您可以像在 Java 文件中的按钮上一样使用这些 FAB。

Let me add that link让我添加那个链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM