Toolbar hiding a piece of textview

Asked

Viewed 30 times

0

Follows code:

<?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:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Color blue = Toolbar and color black = textview.

In the first photo is what is happening now, but behind Toolbar.

How can I solve the same in the second photo ?

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 group everything, except Toolbar, in a Relativelayout and setting the attribute layout_marginTop for "?attr/actionBarSize".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.