Android toolbar occupying all layout space

1

I'm trying to implement a Toolbar implementation in my Android application, but for some reason it takes up all of the screen space. I would like to know why, since I am using the below property in the layout after the toolbar.

activity_main.xml

<RelativeLayout 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=".Main">

    <include
        android:id="@+id/tool_bar"
        layout="@layout/tool_bar"></include>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tool_bar">

        <LinearLayout
            android:id="@+id/llLogotipo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imgLogotipo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/dmufscar" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/frmbotoes"
            android:layout_width="fill_parent"
            android:layout_height="100dp"
            android:layout_below="@+id/llLogotipo"
            android:orientation="horizontal">

            <Button
                android:id="@+id/btnIniciarRFID"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="RFID" />

            <Button
                android:id="@+id/btnPatrimonio"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="@string/btnPatrimonio" />
        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>

tool_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:elevation="4dp">


</android.support.v7.widget.Toolbar>
    
asked by anonymous 18.08.2015 / 03:45

1 answer

2

In your toolbar.xml file, make the following changes:

  • Change the line android:layout_height="match_parent" to

    android:layout_height="wrap_content"    
    
  • Add the following line:

    android:minHeight="?attr/actionBarSize"
    
  • 18.08.2015 / 05:45