0

I have one activity containing 2 fragments as a Tab-layout when i touched first fragment(tab) it required scrolling its working fine but when i touched second fragment(tab) i don't want collapsing toolbar-layout only two fragments tabs i want in that tab so help me if you know this.XML containing

enter code here

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapse_toolbar"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <ImageView
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#424242"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"

            app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="top"

 app:layout_collapseMode="pin"
          />


        <Relative-layout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           ">

            <Text-view
          />

         <Text-view

                 />

            <View
                android:id="@+id/view"
                android:layout_width="wrap_content"
                android:layout_height="2dp"
               />

            <Image View

             />

        </RelativeLayout>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs
            android:layout_gravity="bottom"
           />

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

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


<android.support.v4.view.ViewPager

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
  />

Shreyas
  • 1
  • 6

1 Answers1

0

Set a TabSelected listener, and when your second tab is selected, collapse the toolbar via appBarLayout.SetExpanded(false, true);, and set it's height to be smaller.
See here and here.

Community
  • 1
  • 1
amitairos
  • 2,743
  • 8
  • 38
  • 80