android - 浮动操作按钮未在 Android 中显示图像?
问题描述
正如标题所说,我不知道如何解决这个问题。我读过这个问题,但那是在 2018 年,我对所有这些库和依赖项都不是很熟悉。但是从我声明的依赖项来看,从 Android Studio 来看,这就是我得到的:
我想在 FAB 中添加某种“附加文档”图标/图像。我试图通过添加新矢量资产来做到这一点,但图像没有出现在我的可绘制文件夹中。如何找到一些不错的图标/图像并将其设置为 FAB?
这是 XML:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:icon="@drawable/attache_file">
</com.google.android.material.floatingactionbutton.FloatingActionButton>
解决方案
我找到了解决方案,只需在 dimens.xml 中添加以下语句
<dimen name="design_fab_image_size" tools:override="true">56dp</dimen>
并且必须在您的 FAB 设计 xml中添加app:tint="@null"
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/bottomBar"
app:srcCompat="@drawable/ic_logo"
app:tint="@null" />```
Happy to help :)
推荐阅读
- python - Flask 服务器端会话
- c# - 如何在 c# 属性中使用字符串格式?
- python - Python:选择来自多个用户的最新条目的行
- typescript - 基类返回对扩展类类型不匹配的引用
- javascript - 函数在反应JSX中没有返回值
- android - 使用 sharedPreferences 获取 NullPointerException
- html - CSS - 将我的导航栏水平放置
- c - C 上的 SMTP 服务器
- python - 在自定义数据集上重新训练 tensorflow 模型(resnet 和 inceptionV3)
- python - 创建用于通过python访问多个excel表的超链接