我有一个充满自定义视图的应用程序.当我尝试以编程方式创建FAB时,它会抛出错误
引起:java.lang.IllegalArgumentException:您需要将Theme.AppCompat主题(或后代)与设计库一起使用.
这是我的代码.
private FloatingActionButton getFAB() {
FloatingActionButton fab = new FloatingActionButton(getContext());
fab.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_add_white_24dp));
return fab;
}
Run Code Online (Sandbox Code Playgroud)
这是我的应用主题.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Run Code Online (Sandbox Code Playgroud)
请帮我.