set icon to fab programmatically in android studio

Solutions on MaxInterview for set icon to fab programmatically in android studio by the best coders in the world

showing results for - "set icon to fab programmatically in android studio"
Alberto
20 Jun 2019
1if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
2            floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_full_sad, context.getTheme()));
3        } else {
4            floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_full_sad));
5    }
6
Irene
29 Jan 2020
1floatingActionButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_full_sad));