【问题标题】:Where can I find the icon for a floating action button in android studio? [duplicate]我在哪里可以找到 android studio 中浮动操作按钮的图标? [复制]
【发布时间】:2017-02-03 10:57:04
【问题描述】:

我试过用谷歌搜索一张图片,但我想知道是否有办法让我在布局文件中使用十六进制指定浮动操作按钮的颜色。 我希望颜色与应用程序的其余部分有意义。

【问题讨论】:

标签: android android-layout android-studio icons floating-action-button


【解决方案1】:

您可以通过 FloatingActionButton XML 中的app:backgroundTint 属性更改 FAB 的颜色

<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_myicon"
app:backgroundTint="@color/mycolor"
app:fabSize="normal"
app:elevation="5dp">

【讨论】:

  • 这适用于我从谷歌下载的图片吗?我的 drawables 目录中没有 FAB 图标。
  • 是的,它会完美无瑕,但请务必使用 png 图像作为图标
【解决方案2】:

您可以在 syles.xml 中使用 colorAccent 设置浮动操作按钮颜色:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/drawer_toggle</item>
</style>

或者如果你不想改变colorAccent,你可以像deejay所说的那样使用backgroundTint。

【讨论】:

  • 如果我从 google 下载图像并将其放在我的 drawables 目录中,这会起作用吗?我的 drawables 目录没有带有浮动操作按钮图标
猜你喜欢
  • 1970-01-01
  • 2018-09-24
  • 2013-12-27
  • 1970-01-01
  • 2019-01-07
  • 2016-03-02
  • 1970-01-01
  • 2015-10-01
  • 2017-08-16
相关资源
最近更新 更多