LinearLayout overlapping Support CoordinatorLayout

It’s the first time I use CoordinatorLayout, and I don’t really understand how it works.

My LinearLayout is overlapping my Toolbar, as if I were in a FrameLayout, or RelativeLayout, and I don’t know how to tell it to go below ( Like android:layout_below with RelativeLayout )

  • Android Gradient drawable programmatically
  • How do I separate the metadata and the track from a shoutcast stream without making separate request for metadata and the streaming
  • Skip some fragments onBackPressed
  • Can't detect Android in web server
  • Android devices not having JIT
  • Android camera preview stretched using Grafika CameraCapture code
  • Here is my code:

    <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">
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="192dp"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    
            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">
    
                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:src="@drawable/logo2"
                    app:layout_collapseMode="pin" />
    
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/appbar"
            android:orientation="vertical"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin">
    
                .... Very Large Form ...
        </LinearLayout>
    </android.support.design.widget.CoordinatorLayout>
    

    Another doubt: Almost all the examples I saw were with CoordinateLayout managing RecyclerView.
    My Layout is not a RecyclerView, just a very long form. Does it make sense doing it this way?

    Related posts:

    How do I pass an object from one activity to another on Android?
    Optimizing drawer and activity launching speed
    Close Android popup window with back press
    If an activity is killed, does the AsyncTask live on?
    Get list of installed android applications
    SIG33 when debugging native Android
  • Why can't one add/remove items from an ArrayAdapter?
  • How to upgrade appengine-java-sdk installed in .gradle folder
  • Installing Android Studio, does not point to a valid JVM installation error
  • Why does the WebViewDemo die?
  • Get the file size in android sdk?
  • Selector requires drawable attribute?
  • 3 Solutions collect form web for “LinearLayout overlapping Support CoordinatorLayout”

    Try nesting your content inside of a NestedScrollView. Don’t forget to include the layout_behavior XML tag.

     <android.support.v4.widget.NestedScrollView
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
         <!-- Your scrolling content -->
    
     </android.support.v4.widget.NestedScrollView>
    

    Additional resources:
    http://developer.android.com/reference/android/support/design/widget/AppBarLayout.html

    Late answer, but it might still help someone.

    Enclose all the chidren of CoordinatorLayout into a LinearLayout, vertical orientation.
    It worked for me.

    From developer.android.com

    “CoordinatorLayout is a super-powered FrameLayout.
    CoordinatorLayout is intended for two primary use cases:
    As a top-level application decor or chrome layout
    As a container for a specific interaction with one or more child views
    By specifying Behaviors for child views of a CoordinatorLayout you can provide many different interactions within a single parent and those views can also interact with one another. View classes can specify a default behavior when used as a child of a CoordinatorLayout using the DefaultBehavior annotation.
    Behaviors may be used to implement a variety of interactions and additional layout modifications ranging from sliding drawers and panels to swipe-dismissable elements and buttons that stick to other elements as they move and animate.
    Children of a CoordinatorLayout may have an anchor. This view id must correspond to an arbitrary descendant of the CoordinatorLayout, but it may not be the anchored child itself or a descendant of the anchored child. This can be used to place floating views relative to other arbitrary content panes.”

    So, you can change the root view to LinearLayout(vertical orientation) or use scrollview, which would arrange the children linearly.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.