【问题标题】:How to add a FloatingActionButton to the toolbar?如何将 FloatingActionButton 添加到工具栏?
【发布时间】:2016-06-07 08:59:54
【问题描述】:

问题: 我需要将implementation 的两个FAB 添加到工具栏。 将两个按钮都放在右下角似乎占用了太多屏幕空间。

问题: 如何将 FloatingActionButton 添加到工具栏?

【问题讨论】:

  • 你想添加 FloatingActionButton 还是 FloatingActionButton 有进度?
  • 带有进度的浮动操作按钮 - 操作按钮的进度指示器是我想要它的原因。如果一个普通的按钮就足够了,我会在菜单中添加一个简单的项目
  • 尝试为工具栏创建自定义布局

标签: android xml android-studio toolbar floating-action-button


【解决方案1】:

您问题中的所有元素都是简单的View。全部!

这意味着,您所要做的就是在您希望它们出现的位置上构建带有视图的布局。就像使用 LinearLayout、RelativeLayout、ImageView、TextView 等一样。

具体实现会因您实际想要的样子而异。但可能类似于以下伪 XML 的内容应该可以帮助您入门。

<LinearLayout orientation=vertical>

   <AppBarLayout>
      <Toolbar />

      <com.github.jorgecastilloprz.FABProgressCircle>
         <android.support.design.widget.FloatingActionButton />
      </com.github.jorgecastilloprz.FABProgressCircle>
   </AppBarLayout>

   <FrameLayout height=match_parent>
        ... your app content comes here
   </FrameLayout>

</LinearLayout>

【讨论】:

    猜你喜欢
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    相关资源
    最近更新 更多