Toolbar is in front

3

I have a problem where my toolbar is in front of my view. I have a scroll view and when I slide up it stays like this. Follow the xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">

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

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/colorPrimary"
    app:theme="@style/ThemeOverlay.AppCompat.Dark" />

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

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="60dp">

        <FrameLayout
            android:id="@+id/cont_foto"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:background="@color/colorPrimary"
            android:gravity="center"
            android:orientation="vertical">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/imageContact"
                android:layout_width="150dp"
                android:layout_height="150dp"
                android:layout_gravity="center"
                android:src="@mipmap/cliente_cadastrado" />

            <ImageButton
                android:id="@+id/galeria"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_gravity="center"
                android:layout_marginBottom="40dp"
                android:layout_marginEnd="-65dp"
                android:layout_marginRight="-65dp"
                android:alpha="1"
                android:background="@drawable/circ_white"
                android:padding="5dp"
                android:scaleType="fitCenter"
                android:src="@drawable/ic_camera" />

            <ImageButton
                android:id="@+id/camera"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_gravity="center"
                android:layout_marginEnd="-75dp"
                android:layout_marginRight="-75dp"
                android:alpha="1"
                android:background="@drawable/circ_white"
                android:padding="5dp"
                android:scaleType="fitCenter"
                android:src="@drawable/ic_imagem" />


        </FrameLayout>


        <android.support.design.widget.TextInputLayout
            android:id="@+id/fNameLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/cont_foto"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:singleLine="true">

            <EditText
                android:id="@+id/tvName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Nome"
                android:singleLine="true" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/lNameLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/fNameLayout"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp">

            <EditText
                android:id="@+id/phone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Celular"
                android:inputType="phone"
                android:singleLine="true" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/ageLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/lNameLayout"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp">

            <EditText
                android:id="@+id/email"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Email"
                android:singleLine="true" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/phoneLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ageLayout"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp">

            <EditText
                android:id="@+id/endereco"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="@string/hint_cel"
                android:singleLine="true" />

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

    </RelativeLayout>

</ScrollView>

Follow the prints:

    
asked by anonymous 18.07.2016 / 13:38

2 answers

2

Try to add your toolbar inside the scrollView, so it will also go up when you scroll:

      <LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/main_content"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          android:orientation="vertical">

      <ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior">

          <RelativeLayout
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:paddingBottom="60dp">

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

          <android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:background="@color/colorPrimary"
              app:theme="@style/ThemeOverlay.AppCompat.Dark" />

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

              <FrameLayout
                  android:id="@+id/cont_foto"
                  android:layout_width="match_parent"
                  android:layout_height="250dp"
                  android:background="@color/colorPrimary"
                  android:gravity="center"
                  android:orientation="vertical">

                  <de.hdodenhof.circleimageview.CircleImageView
                      android:id="@+id/imageContact"
                      android:layout_width="150dp"
                      android:layout_height="150dp"
                      android:layout_gravity="center"
                      android:src="@mipmap/cliente_cadastrado" />

                  <ImageButton
                      android:id="@+id/galeria"
                      android:layout_width="40dp"
                      android:layout_height="40dp"
                      android:layout_gravity="center"
                      android:layout_marginBottom="40dp"
                      android:layout_marginEnd="-65dp"
                      android:layout_marginRight="-65dp"
                      android:alpha="1"
                      android:background="@drawable/circ_white"
                      android:padding="5dp"
                      android:scaleType="fitCenter"
                      android:src="@drawable/ic_camera" />

                  <ImageButton
                      android:id="@+id/camera"
                      android:layout_width="40dp"
                      android:layout_height="40dp"
                      android:layout_gravity="center"
                      android:layout_marginEnd="-75dp"
                      android:layout_marginRight="-75dp"
                      android:alpha="1"
                      android:background="@drawable/circ_white"
                      android:padding="5dp"
                      android:scaleType="fitCenter"
                      android:src="@drawable/ic_imagem" />


              </FrameLayout>


              <android.support.design.widget.TextInputLayout
                  android:id="@+id/fNameLayout"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_below="@+id/cont_foto"
                  android:layout_centerHorizontal="true"
                  android:layout_marginTop="20dp"
                  android:singleLine="true">

                  <EditText
                      android:id="@+id/tvName"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:ems="10"
                      android:hint="Nome"
                      android:singleLine="true" />

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

              <android.support.design.widget.TextInputLayout
                  android:id="@+id/lNameLayout"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_below="@+id/fNameLayout"
                  android:layout_centerHorizontal="true"
                  android:layout_marginTop="10dp">

                  <EditText
                      android:id="@+id/phone"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:ems="10"
                      android:hint="Celular"
                      android:inputType="phone"
                      android:singleLine="true" />

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

              <android.support.design.widget.TextInputLayout
                  android:id="@+id/ageLayout"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_below="@+id/lNameLayout"
                  android:layout_centerHorizontal="true"
                  android:layout_marginTop="10dp">

                  <EditText
                      android:id="@+id/email"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:ems="10"
                      android:hint="Email"
                      android:singleLine="true" />
              </android.support.design.widget.TextInputLayout>

              <android.support.design.widget.TextInputLayout
                  android:id="@+id/phoneLayout"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_below="@+id/ageLayout"
                  android:layout_centerHorizontal="true"
                  android:layout_marginTop="10dp">

                  <EditText
                      android:id="@+id/endereco"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:ems="10"
                      android:hint="@string/hint_cel"
                      android:singleLine="true" />

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

          </RelativeLayout>

      </ScrollView>
    
18.07.2016 / 14:18
0
<android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:contentScrim="@color/colorPrimary"
        app:expandedTitleTextAppearance="@style/TransparentText"
        app:layout_scrollFlags="scroll|enterAlways|snap">

       <android.support.v7.widget.Toolbar
            android:id="@+id/toolbarSearch"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/defaultColorBackground"
            app:popupTheme="@style/AppTheme.AppBarOverlay"
            app:theme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>

With this code you will make your Toolbar roll obeying all the content. Remembering that the ScrollView should contain the:

<app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    
02.05.2017 / 13:25