Android P visibilityawareimagebutton.setVisibility can only be called from the same library group
Solution 1:
Using Method 1
demoFab.show(); // in place of visible
demoFab.hide(); // in place of Invisible suppress the warning/error for me.
and Method 2
@SuppressLint("RestrictedApi") // also suppressed the warning
private void setUp() {
....
}
update:
Method 3:
demoFab.setVisibility(View.GONE);
demoFab.setVisibility(View.INVISIBLE);
demoFab.setVisibility(View.VISIBLE);
Method 4:
demoFab.visibility = View.GONE
demoFab.visibility = View.INVISIBLE
demoFab.visibility = View.VISIBLE
Solution 2:
Seems to work fine just to cast it to a view.
(mFloatingActionButton as View).visibility = INVISIBLE
Of course you need to remember that the visibility may affect other components, so you should probably use show()
and hide()
at the same time to make sure other components are notified of the change.