Palang Palang - 6 months ago 31
Android Question

How to hide FAB is show in Android

I am using this library

FAB
: FABToolbar

I want to hide fab button when isShow it, and i want to write this code in
onBackPress
method but this code show me error.


onBackPress method:

@Override
public void onBackPressed() {
if (fabToolbar.show()) {
fabToolbar.hide();
} else {
onBackPressed();
}
}


but show me this error :

enter image description here

How can i fix this problem and check isShow for this FAB ?

N J N J
Answer

If you look properly in library isToolbar()

isToolbar() return true if ToolBar is visible else it will return false

public boolean isToolbar() {
    return isToolbar;
}

EDIT

if (fabToolbar.isToolbar()) {
        fabToolbar.hide();
    } else 
      super.onBackPressed();
    }