Reputation: 1673
I am implementing a list view in my app. I am trying to build my app for android 6.0 and chosen the theme "DarkActionBar". I am having this code right now in activity_main.xml.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.mycompany.www.mynotes.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</android.support.design.widget.CoordinatorLayout>
I have just added a listview (replacing a textview) in this code. Rest of code was already there when I created my project.
Right now I am adding some items randomly in the listview. Now the problem is, the top most item of list view gets behind the toolbar as shown in the image below. How to fix it? I want this listview to start below the toolbar.
Upvotes: 0
Views: 729
Reputation: 15798
You have to add app:layout_behavior
to your LiveView
:
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
Upvotes: 1