Floating Action Button icon image not showing after hide and show
I know it has been a long time since you posted this but I had the same problem. I solved it by doing a hide() and then a show() to the fab after clicking. (In my particular case I change the drawable in onClick. Doing hide() and show() after changing the drawable solved the issue).
Your code shall look like:
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
fab.setImageResource(R.drawable.ic_close);
} else {
sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
fab.setImageResource(R.drawable.ic_filter);
}
fab.hide();
fab.show();
}
});
Did face the same issue with dependency com.google.android.material:material:1.0.0
. Upgrading the version to 1.1.0-alpha3
fixed the issue.