Android - Como criar FAB programaticamente?
Eu tenho um aplicativo cheio de visualizações personalizadas. Quando tento criar um FAB programaticamente, ele gera um erro
Causado por: java.lang.IllegalArgumentException: você precisa usar um tema Theme.AppCompat (ou descendente) com a biblioteca de design.
Aqui está o meu código.
private FloatingActionButton getFAB() {
FloatingActionButton fab = new FloatingActionButton(getContext());
fab.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_add_white_24dp));
return fab;
}
Este é o meu tema do aplicativo.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Por favor me ajude.