You need to use a Theme.AppCompat theme (or descendant) with the design library

今天遇到一个奇葩的问题,在使用android design控件FloatingActionButton的时候报错了,报错内容如下:

Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.

        at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:33)
        at android.support.design.widget.FloatingActionButton.(FloatingActionButton.java:164)

        at android.support.design.widget.FloatingActionButton.(FloatingActionButton.java:158)

我明明导入了com.android.support:design:27.1.1这个包,但还是不行,如下

You need to use a Theme.AppCompat theme (or descendant) with the design library_第1张图片

最后终于找到了解决方案:

在清单文件AndroidManifest.xml中将application的theme改成@style/Theme.AppCompat.Light.NoActionBar就可以了;

如图  

You need to use a Theme.AppCompat theme (or descendant) with the design library_第2张图片

你可能感兴趣的:(design,android,bug,design,library)