How to create Collapsing Toolbar only for one piece?

I have a few fragments which I switch between using the Navigation Drawer. In one of the fragments I need to use a Collapsing Toolbar with the picture, others have standarntyy Toolbar, but collapsing toolbar appears below normal. How to fix it? Here is xml fragment
<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/annonce.main.coordinator" android:layout_width="parent" android:layout_height="parent" android:fitssystemwindows="true" tools:ignore="RtlHardcoded">

<android.support.design.widget.appbarlayout android:id="@+id/flexible.example.appbar" android:layout_width="parent" android:layout_height="wrap content" android:fitssystemwindows="true" android:theme="@style/AppTheme.NoActionBar">

 <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/flexible.example.collapsing" android:layout_width="parent" android:layout_height="300dp" app:title="User NAme" app:expandedtitlemarginbottom="94dp" app:layout_scrollflags="scroll|exitUntilCollapsed" android:fitssystemwindows="true" app:contentscrim="?colorPrimary">

 <imageview android:layout_width="fill_parent" android:layout_height="parent" android:src="@drawable/test4" android:tint="#BB3E50B4" android:scaletype="centerCrop" app:layout_collapsemode="parallax">

 <android.support.v7.widget.toolbar android:id="@+id/flexible.example.toolbar" android:layout_width="parent" android:layout_height="?attr/actionBarSize" android:background="@null" app:layout_collapsemode="pin">
</android.support.v7.widget.toolbar></imageview></android.support.design.widget.collapsingtoolbarlayout>
</android.support.design.widget.appbarlayout></android.support.design.widget.coordinatorlayout>

Here styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
 <item name="colorPrimary">@color/colorPrimary</item>
 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
 <item name="colorAccent">@color/colorAccent</item>
</style>

Here activity_main.xml
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="parent" android:layout_height="parent" android:fitssystemwindows="true" tools:opendrawer="start">

<android.support.design.widget.coordinatorlayout android:id="@+id/content" android:layout_width="parent" android:layout_height="parent" android:orientation="vertical">

 <android.support.design.widget.appbarlayout android:id="@+id/appBarLayout" android:layout_width="parent" android:layout_height="wrap content">

 <android.support.v7.widget.toolbar android:layout_width="parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:elevation="@dimen/default_elevation" app:layout_scrollflags="scroll|enterAlways" app:theme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.toolbar>

</android.support.design.widget.appbarlayout>

 <android.support.v7.widget.recyclerview android:id="@+id/rvFeed" android:layout_width="parent" android:layout_height="parent" android:scrollbars="none" app:layout_behavior="@string/appbar_scrolling_view_behavior">

 <include layout="@layout/content_main">

</include></android.support.v7.widget.recyclerview></android.support.design.widget.coordinatorlayout>


<android.support.design.widget.navigationview android:id="@+id/nav_view" android:layout_width="wrap content" android:layout_height="parent" android:layout_gravity="start" android:fitssystemwindows="true" app:headerlayout="@layout/view_global_menu_header" app:menu="@menu/activity_main_drawer"></android.support.design.widget.navigationview></android.support.v4.widget.drawerlayout>

The result should be something like this
5a2fe8986c0b8910742869.jpeg
June 10th 19 at 15:48
1 answer
June 10th 19 at 15:50
Solution
It is implied that CollapsingToolbar used on individual activity instead of the fragment to provide easy navigation for the "Back" button and reduce the number of unnecessary actions in the parent view.
If this approach is still necessary, it is necessary to create a theme containing:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

And then restart the activity by calling setTheme(theme without the toolbar) before setContentView().

Another option. Trivial to set the height of the toolbar to 0.
You need to have access to navigation drawer - Camryn.Hegmann21 commented on June 10th 19 at 15:53
he remains a swipe to the right, and the toolbar and in the snippet there, it is only necessary to initialize. - Maxin commented on June 10th 19 at 15:56
I don't understand. What do you suggest I do? You need to CollapsingToolbar was in one of fragmentov (not activity) and NavigationDrawer to the top was available as a hamburger. (I threw in a photo from the app VK. There they once did?) - Camryn.Hegmann21 commented on June 10th 19 at 15:59
and you can make CollapsingToolbar was spelled out in the activity_main, but show only one fragment? - Camryn.Hegmann21 commented on June 10th 19 at 16:02
you have a toolbar in a fragment is declared. Initisl it using setSupportActionBar(), the toolbar aktiviti will be replaced by the toolbar fragment, the same way back. - Maxin commented on June 10th 19 at 16:05
in the movie, you cannot use setSupportActionBar () only in activiti - Camryn.Hegmann21 commented on June 10th 19 at 16:08
can. - Maxin commented on June 10th 19 at 16:11

Find more questions by tags JavaAndroid