Double Toolbar Is Showing on Fragment
<p><a href="https://i.stack.imgur.com/rZ1DO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rZ1DO.jpg" alt="Double Toolbar is coming "></a></p>

<p>Hello Guys,</p>

<p>My problem is related to double toolbar is coming in my app while inflating(or say replacing) a fragment.
I have an activity class which contains navigation drawer with it's toolbar with navigation toolbar icon.</p>

<p>There is some fragment i don't want to show the activity toolbar i need to show only fragment toolbar : </p>

<p>But while replacing it's showing activity as well as fragment toolbar , any suggestion helpful to me.</p>

<p>I have given the try :</p>

<p>My Fragment :</p>

<pre><code>public class FoodDetailsFragment extends Fragment{
    View view;
    private Toolbar toolbar;
    private ImageView imageView,tabBg;
    private CollapsingToolbarLayout collapsingToolbar;
    private TabPagerAdapter tabPagerAdapter;
    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    CoordinatorLayout.Behavior behavior;
    SendMessage listener;

     public  interface SendMessage{
        void sendData(String s);
}

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try{
            listener= (SendMessage) activity;

        }catch (ClassCastException exp){
            throw new ClassCastException("Class Cast Exp");
        }


    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       view=inflater.inflate(R.layout.food_details,container,false);
        setHasOptionsMenu(true);
        listener.sendData("ds");

        imageView= (ImageView) view.findViewById(R.id.backdrop);
        tabBg= (ImageView) view.findViewById(R.id.tabBg);
        collapsingToolbar=(CollapsingToolbarLayout) view.findViewById(R.id.collapsing_toolbar);

        setToolbar(view);
        setImage();

        mViewPager= (ViewPager) view.findViewById(R.id.viewpager);
        mTabLayout= (TabLayout) view.findViewById(R.id.detail_tabs);
        tabPagerAdapter=new TabPagerAdapter(getActivity().getSupportFragmentManager());
        mViewPager.setAdapter(tabPagerAdapter);
        mTabLayout.setTabsFromPagerAdapter(tabPagerAdapter);
        mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        mTabLayout.setupWithViewPager(mViewPager);

        mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                if(position==0){
                    Glide.with(getActivity()).load(R.drawable.onet).into(imageView);
                    Glide.with(getActivity()).load(R.drawable.oneb).into(tabBg);
                } else {
                    Glide.with(getActivity()).load(R.drawable.twot).into(imageView);
                    Glide.with(getActivity()).load(R.drawable.twob).into(tabBg);
                }
                imageView.invalidate();
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        return view;


    }
    private void setToolbar(View view) {
        toolbar= (Toolbar) view.findViewById(R.id.toolbarone);

        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

       ((AppCompatActivity) getActivity()).getSupportActionBar();
        ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(true);




        if (toolbar != null) {
            ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
        }


    }
    private void setImage() {
        Glide.with(this).load(R.drawable.resfor).into(imageView);
        Glide.with(getActivity()).load(R.drawable.resone).into(tabBg);
    }
    class TabPagerAdapter extends FragmentStatePagerAdapter {

        public TabPagerAdapter(FragmentManager fm){
            super(fm);
        }
        @Override
        public Fragment getItem(int position) {

            switch (position){
                case 0:
                    FoodDetailedInfoFragment tab1 = new FoodDetailedInfoFragment();
                    return tab1;
                case 1:
                    FoodReviewFragment tab2 = new FoodReviewFragment();
                    return tab2;

                default:
                    return null;
            }




        }

        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            if(position==0){
                return "INFO";
            }else if(position==1){
                return "REVIEW";
            }


            return "INFO" ;
        }
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.my_custom_menu, menu);
        super.onCreateOptionsMenu(menu, inflater);
    }

}
</code></pre>

<p>Fragment xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="256dp"

        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;

        &lt;android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;

            &lt;ImageView

                android:id="@+id/backdrop"

                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="fitXY"
                app:layout_collapseMode="none" /&gt;

            &lt;android.support.v7.widget.Toolbar
                android:id="@+id/toolbarone"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;


            &lt;/android.support.v7.widget.Toolbar&gt;


        &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;

    &lt;/android.support.design.widget.AppBarLayout&gt;

    &lt;FrameLayout
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"

        app:layout_anchor="@+id/appbar"
        app:layout_anchorGravity="bottom"
        app:layout_collapseMode="none"&gt;

        &lt;ImageView
            android:id="@+id/tabBg"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorPrimary"
            android:scaleType="fitXY" /&gt;

        &lt;android.support.design.widget.TabLayout
            android:id="@+id/detail_tabs"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:tabMaxWidth="0dp"
            android:layout_gravity="bottom"
            android:background="#00000000"
            app:layout_anchor="@+id/appbar"
            app:layout_anchorGravity="bottom"
            app:layout_collapseMode="none"
            app:tabGravity="fill"



            app:tabIndicatorColor="#fff"
            app:tabIndicatorHeight="2dp"
            app:tabMode="scrollable"
            app:tabSelectedTextColor="#fff"
            app:tabTextColor="#fff" /&gt;

    &lt;/FrameLayout&gt;


    &lt;android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;
&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p>Splash Activity xml:</p>

<pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"&gt;

    &lt;android.support.design.widget.CoordinatorLayout
        android:id="@+id/container_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"&gt;

        &lt;RelativeLayout
            android:id="@+id/rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;
        &lt;android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;

            &lt;android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:elevation="4dp"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /&gt;

        &lt;/android.support.design.widget.AppBarLayout&gt;




            &lt;FrameLayout
                android:layout_below="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:background="@color/faintwhite"
                android:id="@+id/container"&gt;

            &lt;/FrameLayout&gt;





        &lt;/RelativeLayout&gt;

        &lt;android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:layout_margin="@dimen/spacing"
            android:src="@drawable/ic_share_grey_600_24dp"
            app:backgroundTint="@color/colorAccent" /&gt;

    &lt;/android.support.design.widget.CoordinatorLayout&gt;


    &lt;!-- Navigation Drawer--&gt;
    &lt;android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:background="#000000"&gt;

    &lt;/android.support.v7.widget.RecyclerView&gt;

&lt;/android.support.v4.widget.DrawerLayout&gt;






&lt;!--
&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;android.support.v4.widget.DrawerLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:elevation="7dp"&gt;


&lt;FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:background="@color/faintwhite"
    android:id="@+id/container"&gt;
    &lt;include
        android:id="@+id/tool_bar"
        layout="@layout/app_bar"/&gt;
&amp;lt;!&amp;ndash;&lt;RelativeLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    &gt;
    &lt;include
        android:id="@+id/tool_bar"
        layout="@layout/app_bar"/&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center"

        android:layout_below="@+id/tool_bar"&gt;
    &lt;LinearLayout
        android:id="@+id/lin_lay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"&gt;
        &lt;ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"


            /&gt;
    &lt;/LinearLayout&gt;

    &lt;LinearLayout
        android:id="@+id/linear2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"&gt;
        &lt;ImageView
            android:id="@+id/img"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            /&gt;
    &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;

&lt;/RelativeLayout&gt;&amp;ndash;&amp;gt;

&lt;/FrameLayout&gt;

    &lt;android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/white"
        app:headerLayout="@layout/drawer_header"
        app:itemIconTint="@drawable/drawer_icon_selector"
        app:itemTextColor="@drawable/drawer_text_selector"
        app:menu="@menu/drawer" /&gt;

    &amp;lt;!&amp;ndash;&lt;android.support.v7.widget.RecyclerView
        android:id="@+id/RecyclerView"
        android:layout_width="320dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"

        android:background="#ffffff"
        android:scrollbars="vertical"&gt;

    &lt;/android.support.v7.widget.RecyclerView&gt;&amp;ndash;&amp;gt;
    &lt;/android.support.v4.widget.DrawerLayout&gt;--&gt;
</code></pre>