【问题标题】:FloatingActionButton doesn't change in xml layout [duplicate]FloatingActionButton 在 xml 布局中没有改变[重复]
【发布时间】:2021-07-02 09:25:18
【问题描述】:

我的浮动操作按钮看起来像this.

它应该显示一个加号图标。

我的代码:

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.tasks.TasksFragment">

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recycler_view_tasks"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab_add_task"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="16dp"
    android:src="@drawable/ic_add" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

【问题讨论】:

    标签: android xml floating-action-button


    【解决方案1】:

    app:srcCompat代替android:src

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab_add_task"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        app:srcCompat="@drawable/ic_add" />
    

    【讨论】:

      猜你喜欢
      • 2012-01-18
      • 2015-10-22
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-19
      相关资源
      最近更新 更多