Android - How to create FAB programmatically?

后端 未结 1 1593
梦毁少年i
梦毁少年i 2021-01-07 03:57

I have an app with full of custom views. When I try to create a FAB programmatically, it throws an error

Caused by: java.lang.IllegalArgumentExc

相关标签:
1条回答
  • 2021-01-07 04:17

    Fixed by using theme wrapper. But still I'm surprised about using ContextThemeWrapper

    private FloatingActionButton getFAB() {
        Context context = new android.support.v7.internal.view.ContextThemeWrapper(getContext(), R.style.AppTheme);
        FloatingActionButton fab = new FloatingActionButton(context);
        return fab;
    }
    
    0 讨论(0)
提交回复
热议问题