There is a fragment. there is a toolbar in the fragment

Here is the fragment markup:

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:id="@+id/drawer_layour"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <include layout="@layout/toolbar_default" /> <!-- TOOLBAR --> </android.support.design.widget.AppBarLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/layout_order"> <!-- ОСНОВНОЙ КОНТЕНТ ФРАГМЕНТА --> </LinearLayout> </android.support.design.widget.CoordinatorLayout> <android.support.design.widget.NavigationView android:id="@+id/navigation" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:itemTextColor="@color/secondary_text" app:menu="@menu/menu_navigation" app:headerLayout="@layout/navigation_header"> </android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout> 

Markup Toolbar:

 <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/my_toolbar" android:minHeight="?attr/actionBarSize" android:background="@color/primary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="center" android:gravity="center|center_vertical" android:id="@+id/layout_logo" android:transitionName="logo"> <ImageView android:layout_width="40dp" android:layout_height="40dp" android:id="@+id/steering" android:src="@drawable/steering" /> </LinearLayout> </LinearLayout> </android.support.v7.widget.Toolbar> 

Inside the fragment I activate the toolbar:

 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_new_order, container, false); initToolbar(rootView); .... return rootView; } private void initToolbar(View v) { toolbar = (Toolbar) v.findViewById(R.id.my_toolbar); toolbar.setTitle(""); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return false; } }); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); } 

As a result, since Android 5.0 everything is fine, the Toolbar is displayed. But with the SDK below, it’s just not there. And NAvigationDrawer works.

Who faced this problem?

UPD I tried to transfer the toolbar to the Activity, everything is fine, it is displayed as it should. Only I need in a separate fragment.

  • And if you move setSupportActionBar(toolbar); in the onResume() fragment? .. - JuriySPb
  • Nothing led. :( - inkognitum
  • And if you do not use include but in the old fashioned way, grandfather's ways? - Yuriy SPb
  • So also tried. No results. - inkognitum
  • No other options ( - YuriySPb

0