Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable floating action button in android [duplicate]

In simple buttons we do

android:clickable:"false"

button.setEnabled="false"

Is there any way to simply disable floating action button? I repeat i am not asking about hiding i am asking about disabling floating action button.

like image 556
Muhammad Laraib Khan Avatar asked Mar 15 '17 13:03

Muhammad Laraib Khan


People also ask

How do I disable the floating action button?

By default, the FloatingActionButton is enabled. To disable the component, set its disabled property to true .

How do I change the floating action icon on Android?

Add the floating action button to your layout The size of the FAB, using the app:fabSize attribute or the setSize() method. The ripple color of the FAB, using the app:rippleColor attribute or the setRippleColor() method. The FAB icon, using the android:src attribute or the setImageDrawable() method.

How do I turn off the floating action button in flutter?

To disable button in Flutter, just assign the null value to the onPressed parameter of the Button.

What is floating action button in Android?

A floating action button (FAB) performs the primary, or most common, action on a screen. It appears in front of all screen content, typically as a circular shape with an icon in its center. FABs come in three types: regular, mini, and extended.


3 Answers

It can be done just like a button.

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab)         
fab.setEnabled(false);
fab.setEnabled(true);
like image 123
dhayanand baskar Avatar answered Sep 22 '22 18:09

dhayanand baskar


You can use the api

fab.setEnabled(boolean state);

Sample

like image 37
Neji Avatar answered Sep 23 '22 18:09

Neji


If you have your FabButton you can do this:

    FloatingActionButton fab = new FloatingActionButton(getActivity());
    fab.setEnabled(false);

That disables the OnClick() of the FAB

like image 41
Alvaro Avatar answered Sep 23 '22 18:09

Alvaro