1

I'm trying to make a CoordinatorLayout contains a FrameLayout as child. This FrameLayout is later replaced for a Fragment that has as a parent a NestedScrollView.

The problem is that when the fragment is created the FrameLayout is taking a wrong position, like it has some kind of a margin.

In the next picture i show you how is the initial position.

Initial position

This is how should be at the start:

Right position

This is the layout of the activity

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

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="340dp"
        android:orientation="vertical">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/ctlLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center">

                <TextView
                    android:id="@+id/beer_style"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="European Lagers"
                    android:textColor="@color/gray"
                    android:textSize="16sp"/>

                <TextView
                    android:id="@+id/beer_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Birra Peroni"
                    android:textColor="@color/white"
                    android:textSize="24sp"/>

                <de.hdodenhof.circleimageview.CircleImageView
                    xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/beer_image"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_margin="16dp"
                    android:src="@mipmap/logo"
                    app:civ_border_width="2dp"
                    app:civ_border_color="#FF000000"/>

                <com.iarcuschin.simpleratingbar.SimpleRatingBar
                    android:id="@+id/rating_bar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:srb_starSize="28dp"
                    app:srb_numberOfStars="5"
                    app:srb_stepSize="0.5"
                    app:srb_borderColor="@color/black"
                    app:srb_fillColor="@color/gray"
                    app:srb_starCornerRadius="20"/>

            </LinearLayout>

            <!-- Toolbar -->
            <include android:id="@+id/toolbar"
                layout="@layout/toolbar" />
        </android.support.design.widget.CollapsingToolbarLayout>

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

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginEnd="8dp"
        app:behavior_overlapTop="60dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

And this is the Layout that i replace in the FrameLayout

<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="jdeveloper.coriassos.views.fragments.BeerDetailFragment">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginTop="30dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/corner_layout"
        android:orientation="vertical"
        android:layout_margin="8dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/information"
            android:textColor="@color/black"
            android:textSize="20sp"
            android:layout_marginTop="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginBottom="8dp"/>

        <TextView
            android:id="@+id/beer_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/lore_ipsum"
            android:textColor="@color/gray"
            android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginEnd="16dp"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="right"
            android:layout_margin="16dp">

            <TextView
                android:id="@+id/beer_origin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="California, USA"
                android:textColor="@color/gray"/>

            <TextView
                android:id="@+id/beer_abv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Alc. 5,00%"
                android:textColor="@color/gray"/>

        </LinearLayout>

    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginBottom="1dp"
        android:background="@drawable/corner_top_layout">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/available"
            android:textColor="@color/black"
            android:textSize="20sp"
            android:layout_margin="16dp"/>

    </FrameLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/variant_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp" />

</LinearLayout>

1 Answers1

0

decrease the value in

app:behavior_overlapTop="60dp" 

in your FrameLayout

Rajesh Gosemath
  • 1,812
  • 1
  • 17
  • 31
  • This is not the solution, maybe i have to edit the post. If you look the "Initial position" image you can see that the layout is, suddenly, under the toolbar. Look the top corners, should have a radius like in the second image. – Josué de León Santana Nov 11 '16 at 17:40