FloatingActionButton setVisibility() not working
For FloatingActionButton
the setVisibility()
method will give you an error while building with the latest Gradle 6.x
and build-tool 28.x.x
and is not encouraged any more. Instead, use:
fab.hide() // fab.setVisibility(View.GONE)
fab.show() // fab.setVisibility(View.VISIBLE)
Note: Succesfully tested on
Android Studio 3.4.1
,Gradle 6.0
andbuild-tool 28.0.1
Use show and hide methods to show and hide the Floating Action Button
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
// To show the Floating Action Button
fab.show();
// To hide the Floating Action Button
fab.hide();