Listview surpassing Toolbar

Asked

Viewed 83 times

0

Does anyone know why mine listview is overtaking the toolbar? I already put the attribute app:layout_behavior="@string/appbar_scrolling_view_behavior" and yet it won’t.

Lista ultrapassando Toolbar

Code:

<?xml version="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>

2 answers

2


Good night Artur! try this way, I believe it is only because the configuration is missing Below:

<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 added an id for Toolbar and the layout_bellow property for listview, I believe layout_behavior is not necessary for that occasion.

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>

Browser other questions tagged

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