FloatingActionButton doesn't hide

后端 未结 17 960
星月不相逢
星月不相逢 2020-11-30 03:42

I am trying to hide my FloatingActionButton fabLocation programmatically with :

fabLocation.setVisibility(View.GONE)

but it do

17条回答
  •  囚心锁ツ
    2020-11-30 04:14

    It is due to the app:layout_anchor attribute. You must get rid of the anchor before changing visibility:

    CoordinatorLayout.LayoutParams p = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
    p.setAnchorId(View.NO_ID);
    fab.setLayoutParams(p);
    fab.setVisibility(View.GONE);
    

提交回复
热议问题