Toolbar hiding a piece of textview

0

Follow the code below:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
      <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        app:layout_scrollFlags="scroll|enterAlways" />
        <LinearLayout
            android:id="@+id/linearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <Button
                    style="@style/Widget.AppCompat.Button.Colored"
                    android:id="@+id/anterior"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="30dp"
                    android:text="Anterior"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginBottom="16dp" />
                <Button
                    style="@style/Widget.AppCompat.Button.Colored"
                    android:id="@+id/proximo"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="30dp"
                    android:text="Próximo"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginBottom="16dp" />
            </LinearLayout>
        </LinearLayout>
        <TextView
            android:id="@+id/textview_test"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/linearLayout"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:gravity="center"
            android:text="TextView"
            android:textColor="@color/blue"
            android:textSize="28sp"
            android:textStyle="bold|italic"
            android:layout_marginEnd="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp" />
    </RelativeLayout>
</android.support.v4.widget.DrawerLayout>

toolbar.axml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Segue a foto:

  

Blue color = toolbar and black color = textview.

In the first photo is what is happening now, however behind the toolbar.

How can I resolve the same in the second photo?

    
asked by anonymous 23.03.2018 / 20:21

1 answer

1

This layout has the behavior you need:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar"
            app:layout_scrollFlags="scroll|enterAlways" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="?attr/actionBarSize">
            <LinearLayout
                android:id="@+id/linearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:orientation="horizontal">
                <Button
                    style="@style/Widget.AppCompat.Button.Colored"
                    android:id="@+id/anterior"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="30dp"
                    android:text="Anterior"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginBottom="16dp" />
                <Button
                    style="@style/Widget.AppCompat.Button.Colored"
                    android:id="@+id/proximo"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="30dp"
                    android:text="Próximo"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginBottom="16dp" />
            </LinearLayout>
            <TextView
                android:id="@+id/textview_test"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/linearLayout"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:gravity="center"
                android:text="TextView"
                android:textColor="@color/blue"
                android:textSize="28sp"
                android:textStyle="bold|italic"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp" />
        </RelativeLayout>
    </RelativeLayout>
</android.support.v4.widget.DrawerLayout>

What I did was to group everything, by taking the toolbar, in a RelativeLayout and setting the attribute layout_marginTop to "?attr/actionBarSize" .

    
24.03.2018 / 01:55