【问题标题】:Why does my FAB icon have a black box around it?为什么我的 FAB 图标周围有一个黑框?
【发布时间】:2016-04-01 04:30:41
【问题描述】:

我通过下载包含 24dp 图标的 png drawables 的存档,从 android 支持库和 material icons site 的添加图标创建了材质浮动操作按钮。

这是我创建 FAB 的代码:

<android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:elevation="6dp"
        android:src="@drawable/ic_add"
        app:fabSize="normal"
        android:layout_gravity="bottom|right"
        app:layout_anchorGravity="bottom|right|end"
        app:pressedTranslationZ="12dp">

</android.support.design.widget.FloatingActionButton>

这是它在 xml 设计选项卡中的呈现方式:

我能做的不多,因为我有正确的按钮 xml 语法,而且图标显然是透明的,周围没有黑色背景。

【问题讨论】:

  • 在真机上看起来如何?还是模拟器? Xml 对我来说看起来不错
  • 我认为这个问题来自使用过的图像而不是来自代码,你的代码似乎很好
  • 我使用了材料设计图标中的图像。 google.com/design/icons
  • @MinaFawzy 谢谢!您发布的链接中的图标有效!您也是从材料设计图标网站获得的吗?

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


【解决方案1】:

这是一个 android studio 问题。尝试在设备中运行应用程序,按钮可能会正确显示。有关此错误的更多详细信息 - ic_stop_white_*dp.png background is black, not transparent

【讨论】:

    【解决方案2】:

    不是代码的问题,是图片本身的问题,试试这个icon

    【讨论】:

    • 亲爱的陌生人,你救了我的命
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-30
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    相关资源
    最近更新 更多