Listview surpassing toolbar

0

Does anyone know why my listview is exceeding toolbar ? I already put the app:layout_behavior="@string/appbar_scrolling_view_behavior" attribute and it still will not.

Code:

<?xmlversion="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_cliente"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context="com.example.xxxxx.Cliente">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <include layout="@layout/toolbar" />

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

<ListView
    android:id="@+id/listaProduto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="horizontal"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:listitem="@layout/itemproduto" />

<LinearLayout
    android:id="@+id/viewBottom"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:weightSum="100">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="50"
        android:gravity="center">

        <Button
            android:id="@+id/btSalvar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/fechar"
            android:textSize="20sp" />
    </LinearLayout>


</LinearLayout>

    
asked by anonymous 26.09.2017 / 01:53

2 answers

2

Good evening, Arthur! try it this way, I believe it's just because it's missing the below configuration:

<android.support.design.widget.AppBarLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<include layout="@layout/toolbar" />

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

<ListView
android:id="@+id/listaProduto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="horizontal"
android:layout_below="@+id/toolbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listitem="@layout/itemproduto" />

I've added an id to the toolbar and the layout_bellow property for the listView, I believe layout_behavior is not necessary for that occasion.

    
26.09.2017 / 03:11
0

Artur, always try to work with CoordinatorLayout when you want to use AppBarLayout, I always use it as follows:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
    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.support.design.widget.AppBarLayout
    android:id="@+id/appbarTitulosReceber"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <include layout="@layout/toolbar" />

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

<include layout="@layout/content_xxx" /> // onde vai ter seu listview e botão

</android.support.design.widget.CoordinatorLayout>
    
26.09.2017 / 13:09