【问题标题】:how to make FloatingActionButtn filled with image?如何使浮动动作按钮充满图像?
【发布时间】:2016-08-05 23:28:54
【问题描述】:

当我为 FloatingActionButton 设置 Image 时,它​​将在所有方向上都有边距。所以我希望 ActionButton 用图像填充而没有任何边距。

【问题讨论】:

  • 将背景设置为 FloatingActionButton。

标签: android material-design floating-action-button


【解决方案1】:

使用属性

android:src="YOUR_DRAWABLE"

在您的android.support.design.widget.FloatingActionButton XML 布局块中。

同样在你styles.xml,在你使用的风格下(通常是AppTheme)使用

<item name="colorAccent">@android:color/transparent</item>

【讨论】:

    【解决方案2】:

    我认为这是您想要实现的目标。使用此代码。

      <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:fitsSystemWindows="true"
        android:cropToPadding="true"
       android:background="@android:color/primary_text_dark"
        android:src="@drawable/zvam" />
    

    你会得到这样的东西。

    http://i.stack.imgur.com/FC4xg.png

    【讨论】:

      【解决方案3】:

      很抱歉,我没有直接回答您的问题(如果可以的话,我会发表评论),但我认为这不是一个好主意。

      在我看来,您只是想在 FAB 上有一个完成/检查图像。如果是这种情况,您应该使用谷歌材料图标页面中的“完成”图标:https://design.google.com/icons/#ic_done

      另外,请查看 Google 的 FAB 设计指南:https://www.google.com/design/spec/components/buttons-floating-action-button.html

      【讨论】:

        猜你喜欢
        • 2017-11-13
        • 1970-01-01
        • 1970-01-01
        • 2015-08-07
        • 2016-11-26
        • 1970-01-01
        • 2019-03-06
        • 2021-06-20
        • 1970-01-01
        相关资源
        最近更新 更多