0

I want to show/hide Google Material Floating Action button programmatically. I'm using Google Material library

implementation 'com.google.android.material:material:1.1.0'

And use the following code

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    FloatingActionButton fab = findViewById(R.id.fab);

    fab.hide() // This is the method to hide the button as the Documentation But This does not hide the button

    fab.setVisibility(View.GONE) // Neither this work, 
}

Is there any other specific method to hide it?

KZoNE
  • 1,249
  • 1
  • 16
  • 27
  • 2
    Shouldn't be there `R.id.fab`? – SkypeDogg Feb 28 '20 at 12:02
  • Yes @SkypeDogg, It was writing a mistake on this. But the issue is still there – KZoNE Mar 02 '20 at 04:40
  • I am using `FloatingActionButton` inside my project, but I don't import `'com.google.android.material:material:1.1.0'` it is inside `'com.android.support:design:28.0.0'`. I'm not sure if it might be a problem, but it's only difference I can see there, because I hide and show it and it works as it should – SkypeDogg Mar 02 '20 at 08:37

0 Answers0