CollapsingToolbarLayout | Four Layouts inside | First Two Scrollable & Last Two Fixed





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I got a little different requirement related to CollapsingToolbarLayout scrolling. I played with all scrollFlags and collapseMode but no combination worked for me.



Please help me to achieve this requirement.



What I need to implement:
I need to implement an AppBarLayout inside which four views will be placed.




  1. Toolbar (Fixed)

  2. LinearLayout (Fixed)

  3. LinearLayout (Scrollable)

  4. TabLayout (Scrollable)


Content is a recyclerview. For reference I am attaching an screenshot. As you can see in screen, toolbar and layout with red background need to be fixed. And layout with green and blue background need to be scrollable when recyclerview is scrolled up.



enter image description here



I am able to fix toolbar and remaining views scrollable. But not able to fix toolbar and layout with red background. Please help me in this.



Below is my my layout xml-



    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:id="@+id/collapsing_toolbar_appbarlayout"
android:layout_width="match_parent"
android:layout_height="208dp"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleEnabled="false">

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
android:layout_marginTop="160dp"
android:background="#0000ff"
app:layout_collapseMode="none"
app:tabGravity="fill"
app:tabIndicatorColor="#ffffff"
app:tabIndicatorHeight="4dp"
app:tabMode="fixed" />

<LinearLayout
android:id="@+id/title_container1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="104dp"
android:orientation="vertical"
app:layout_collapseMode="none">

<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#00ff00"
android:gravity="center"
android:text="test"
android:textColor="#000000" />
</LinearLayout>

<LinearLayout
android:id="@+id/title_container"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="56dp"
android:orientation="vertical"
app:layout_collapseMode="pin">

<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000"
android:gravity="center"
android:text="test"
android:textColor="#000000" />
</LinearLayout>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/colorPrimary"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:titleTextColor="#ffffff" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/collapsing_toolbar_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/collapsing_toolbar_floating_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="19dp"
android:src="@drawable/calendar"
app:layout_anchor="@id/collapsing_toolbar_recycler_view"
app:layout_anchorGravity="bottom|end" />

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









share|improve this question































    0















    I got a little different requirement related to CollapsingToolbarLayout scrolling. I played with all scrollFlags and collapseMode but no combination worked for me.



    Please help me to achieve this requirement.



    What I need to implement:
    I need to implement an AppBarLayout inside which four views will be placed.




    1. Toolbar (Fixed)

    2. LinearLayout (Fixed)

    3. LinearLayout (Scrollable)

    4. TabLayout (Scrollable)


    Content is a recyclerview. For reference I am attaching an screenshot. As you can see in screen, toolbar and layout with red background need to be fixed. And layout with green and blue background need to be scrollable when recyclerview is scrolled up.



    enter image description here



    I am able to fix toolbar and remaining views scrollable. But not able to fix toolbar and layout with red background. Please help me in this.



    Below is my my layout xml-



        <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
    android:id="@+id/collapsing_toolbar_appbarlayout"
    android:layout_width="match_parent"
    android:layout_height="208dp"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/collapsing_toolbar_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:titleEnabled="false">

    <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:layout_gravity="bottom"
    android:layout_marginTop="160dp"
    android:background="#0000ff"
    app:layout_collapseMode="none"
    app:tabGravity="fill"
    app:tabIndicatorColor="#ffffff"
    app:tabIndicatorHeight="4dp"
    app:tabMode="fixed" />

    <LinearLayout
    android:id="@+id/title_container1"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_marginTop="104dp"
    android:orientation="vertical"
    app:layout_collapseMode="none">

    <android.support.v7.widget.AppCompatTextView
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="#00ff00"
    android:gravity="center"
    android:text="test"
    android:textColor="#000000" />
    </LinearLayout>

    <LinearLayout
    android:id="@+id/title_container"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_marginTop="56dp"
    android:orientation="vertical"
    app:layout_collapseMode="pin">

    <android.support.v7.widget.AppCompatTextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ff0000"
    android:gravity="center"
    android:text="test"
    android:textColor="#000000" />
    </LinearLayout>

    <android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="@color/colorPrimary"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    app:layout_collapseMode="pin"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:titleTextColor="#ffffff" />
    </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
    android:id="@+id/collapsing_toolbar_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/collapsing_toolbar_floating_action_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="19dp"
    android:src="@drawable/calendar"
    app:layout_anchor="@id/collapsing_toolbar_recycler_view"
    app:layout_anchorGravity="bottom|end" />

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









    share|improve this question



























      0












      0








      0








      I got a little different requirement related to CollapsingToolbarLayout scrolling. I played with all scrollFlags and collapseMode but no combination worked for me.



      Please help me to achieve this requirement.



      What I need to implement:
      I need to implement an AppBarLayout inside which four views will be placed.




      1. Toolbar (Fixed)

      2. LinearLayout (Fixed)

      3. LinearLayout (Scrollable)

      4. TabLayout (Scrollable)


      Content is a recyclerview. For reference I am attaching an screenshot. As you can see in screen, toolbar and layout with red background need to be fixed. And layout with green and blue background need to be scrollable when recyclerview is scrolled up.



      enter image description here



      I am able to fix toolbar and remaining views scrollable. But not able to fix toolbar and layout with red background. Please help me in this.



      Below is my my layout xml-



          <?xml version="1.0" encoding="utf-8"?>
      <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent">

      <android.support.design.widget.AppBarLayout
      android:id="@+id/collapsing_toolbar_appbarlayout"
      android:layout_width="match_parent"
      android:layout_height="208dp"
      android:theme="@style/AppTheme.AppBarOverlay">

      <android.support.design.widget.CollapsingToolbarLayout
      android:id="@+id/collapsing_toolbar_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_scrollFlags="scroll|exitUntilCollapsed"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      app:titleEnabled="false">

      <android.support.design.widget.TabLayout
      android:id="@+id/tabs"
      android:layout_width="match_parent"
      android:layout_height="56dp"
      android:layout_gravity="bottom"
      android:layout_marginTop="160dp"
      android:background="#0000ff"
      app:layout_collapseMode="none"
      app:tabGravity="fill"
      app:tabIndicatorColor="#ffffff"
      app:tabIndicatorHeight="4dp"
      app:tabMode="fixed" />

      <LinearLayout
      android:id="@+id/title_container1"
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:layout_marginTop="104dp"
      android:orientation="vertical"
      app:layout_collapseMode="none">

      <android.support.v7.widget.AppCompatTextView
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:background="#00ff00"
      android:gravity="center"
      android:text="test"
      android:textColor="#000000" />
      </LinearLayout>

      <LinearLayout
      android:id="@+id/title_container"
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:layout_marginTop="56dp"
      android:orientation="vertical"
      app:layout_collapseMode="pin">

      <android.support.v7.widget.AppCompatTextView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#ff0000"
      android:gravity="center"
      android:text="test"
      android:textColor="#000000" />
      </LinearLayout>

      <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="56dp"
      android:background="@color/colorPrimary"
      app:contentInsetLeft="0dp"
      app:contentInsetStart="0dp"
      app:layout_collapseMode="pin"
      app:popupTheme="@style/AppTheme.PopupOverlay"
      app:titleTextColor="#ffffff" />
      </android.support.design.widget.CollapsingToolbarLayout>
      </android.support.design.widget.AppBarLayout>

      <android.support.v7.widget.RecyclerView
      android:id="@+id/collapsing_toolbar_recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"
      app:layout_behavior="@string/appbar_scrolling_view_behavior" />

      <android.support.design.widget.FloatingActionButton
      android:id="@+id/collapsing_toolbar_floating_action_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="19dp"
      android:src="@drawable/calendar"
      app:layout_anchor="@id/collapsing_toolbar_recycler_view"
      app:layout_anchorGravity="bottom|end" />

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









      share|improve this question
















      I got a little different requirement related to CollapsingToolbarLayout scrolling. I played with all scrollFlags and collapseMode but no combination worked for me.



      Please help me to achieve this requirement.



      What I need to implement:
      I need to implement an AppBarLayout inside which four views will be placed.




      1. Toolbar (Fixed)

      2. LinearLayout (Fixed)

      3. LinearLayout (Scrollable)

      4. TabLayout (Scrollable)


      Content is a recyclerview. For reference I am attaching an screenshot. As you can see in screen, toolbar and layout with red background need to be fixed. And layout with green and blue background need to be scrollable when recyclerview is scrolled up.



      enter image description here



      I am able to fix toolbar and remaining views scrollable. But not able to fix toolbar and layout with red background. Please help me in this.



      Below is my my layout xml-



          <?xml version="1.0" encoding="utf-8"?>
      <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent">

      <android.support.design.widget.AppBarLayout
      android:id="@+id/collapsing_toolbar_appbarlayout"
      android:layout_width="match_parent"
      android:layout_height="208dp"
      android:theme="@style/AppTheme.AppBarOverlay">

      <android.support.design.widget.CollapsingToolbarLayout
      android:id="@+id/collapsing_toolbar_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_scrollFlags="scroll|exitUntilCollapsed"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      app:titleEnabled="false">

      <android.support.design.widget.TabLayout
      android:id="@+id/tabs"
      android:layout_width="match_parent"
      android:layout_height="56dp"
      android:layout_gravity="bottom"
      android:layout_marginTop="160dp"
      android:background="#0000ff"
      app:layout_collapseMode="none"
      app:tabGravity="fill"
      app:tabIndicatorColor="#ffffff"
      app:tabIndicatorHeight="4dp"
      app:tabMode="fixed" />

      <LinearLayout
      android:id="@+id/title_container1"
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:layout_marginTop="104dp"
      android:orientation="vertical"
      app:layout_collapseMode="none">

      <android.support.v7.widget.AppCompatTextView
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:background="#00ff00"
      android:gravity="center"
      android:text="test"
      android:textColor="#000000" />
      </LinearLayout>

      <LinearLayout
      android:id="@+id/title_container"
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:layout_marginTop="56dp"
      android:orientation="vertical"
      app:layout_collapseMode="pin">

      <android.support.v7.widget.AppCompatTextView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#ff0000"
      android:gravity="center"
      android:text="test"
      android:textColor="#000000" />
      </LinearLayout>

      <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="56dp"
      android:background="@color/colorPrimary"
      app:contentInsetLeft="0dp"
      app:contentInsetStart="0dp"
      app:layout_collapseMode="pin"
      app:popupTheme="@style/AppTheme.PopupOverlay"
      app:titleTextColor="#ffffff" />
      </android.support.design.widget.CollapsingToolbarLayout>
      </android.support.design.widget.AppBarLayout>

      <android.support.v7.widget.RecyclerView
      android:id="@+id/collapsing_toolbar_recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"
      app:layout_behavior="@string/appbar_scrolling_view_behavior" />

      <android.support.design.widget.FloatingActionButton
      android:id="@+id/collapsing_toolbar_floating_action_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="19dp"
      android:src="@drawable/calendar"
      app:layout_anchor="@id/collapsing_toolbar_recycler_view"
      app:layout_anchorGravity="bottom|end" />

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






      android android-toolbar android-collapsingtoolbarlayout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 6:29







      user320676

















      asked Jan 3 at 6:12









      user320676user320676

      248115




      248115
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017158%2fcollapsingtoolbarlayout-four-layouts-inside-first-two-scrollable-last-two%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017158%2fcollapsingtoolbarlayout-four-layouts-inside-first-two-scrollable-last-two%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith