在FloatingActionButton中使用材料设计图标库

问题描述 投票:-1回答:1

我正在制作一个使用带有[+]图标的FloatingActionButton的应用,并且我正在使用Materian Design Icons库来添加图标。有什么方法可以在我的FloatingActionButton中使用该库的材质设计图标?


到目前为止,我的FloatingActionButton代码是

 <com.google.android.material.floatingactionbutton.FloatingActionButton
    android:layout_width="56dp"
    android:layout_height="56dp"/>

我没有太多其他内容,因为我无法在FAB中找到图标

android material-design
1个回答
1
投票

当然,您需要先将图标图像添加到drawable文件夹,然后将图标设置为FAB按钮,如下所示:

  <com.google.android.material.floatingactionbutton.FloatingActionButton
  android:layout_width="56dp"
  android:layout_height="56dp"
  app:srcCompat="@drawable/your_icon"
  />
© www.soinside.com 2019 - 2024. All rights reserved.