android - float 操作按钮 : Setting a custom background is not supported

标签 android kotlin floating-action-button

    <android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/insert_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/add"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp"
        android:layout_alignBottom="@id/list_view"
        android:layout_alignRight="@id/list_view"
        android:background="#649696"
        />

这段代码没问题,但是在两行后面添加就崩溃了

        android:backgroundTint="#649696"
        app:rippleColor="#FFFFFF"

崩溃日志:

在 Android 4.1 之前,方法 android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) 会不正确重写 android.graphics.drawable.Drawable 中的包私有(private)方法 I/FloatingActionButton:不支持设置自定义背景。

等级依赖:

compileSdkVersion 27
defaultConfig {
    applicationId ""
    minSdkVersion 23
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

谁能告诉我如何解决这个问题

最佳答案

不幸的是,如果您甚至不设置背景或色调,也会显示此警告。但是,要摆脱它,您可以设置属性 android:background="@null",这将根据 official materials github repository 中的用户建议忽略它。 。 (此问题的原因是一个内部问题,其中一些 setter 被调用,这可能会在 Material 设计库的 future 版本中修复)

关于android - float 操作按钮 : Setting a custom background is not supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47951471/

相关文章:

Android 位图像素 - 直接写入文件?

kotlin - 如何使用 mockk 模拟 ObjectMapper.readValue()

android - FAB 不 float

javascript - Android WebView 缓存 list 应用程序不刷新 Javascript 文件

android - 服务 Intent 必须明确 : Intent

arrays - "No set method providing array access"-- 为什么在 Kotlin 中会发生这种情况?

android - 如何让 float 按钮停留在布局底部?

android - 向 FloatingActionButton 添加多个行为

android - 修复关于 `layout_marginHorizontal` 的 android studio 警告

Android:将边距设置为单选按钮可绘制的左侧