FloatingActionButton setVisibility() not working

后端 未结 6 1837
闹比i
闹比i 2021-02-07 07:13

I can\'t hide my FloatingActionButton. Here is my code:

XML:



    
         


        
6条回答
  •  無奈伤痛
    2021-02-07 08:13

    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 and build-tool 28.0.1

提交回复
热议问题