AppBarLayout take space after setVisibility(View.GONE)

Your problem is caused by this line

    app:layout_behavior="@string/appbar_scrolling_view_behavior"

You will have to set it programatically on CoordinatorLayout not the actual container fragment that has that field.

Here is how

    mContainer = (FrameLayout) findViewById(R.id.main_content_container);

    CoordinatorLayout.LayoutParams params =
            (CoordinatorLayout.LayoutParams) mContainer.getLayoutParams();
    params.setBehavior(null);

    mContainer.requestLayout();

If you want to make it scrolling again

   params.setBehavior(new AppBarLayout.ScrollingViewBehavior());

Try to set AppBarLayout's height to zero

AppBarLayout appBar=(AppBarLayout)findViewById(R.id.fProfilAppBar);
LinearLayout.LayoutParams params=appBar.getLayoutParams();
params.height=0;
appBar.setLayoutParams(params);