0

I am doing some changes in my app: I would like to add to it a ToolBar since with regular action bar goes over my drawer. But now it seems like I have the opposite problem: My list view goes over my ToolBar.

Can someone please tell me what am I doing wrong? Here is: activity_main.xml

<?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"
    android:id="@+id/drawer_layout"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true">

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

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header"
        app:menu="@layout/drawer_menu"
        app:itemTextColor="#000000"
        />

</android.support.v4.widget.DrawerLayout>

And it calls:

<?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"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <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/ThemeOverlay.AppCompat.Light"
            app:layout_scrollFlags="scroll|enterAlways" />

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


    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/activity_main_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ListView
            android:id="@+id/custom_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:cacheColorHint="#00000000"
            android:divider="@null"
            android:dividerHeight="0px"
            android:focusable="false"
            android:visibility="gone">

        </ListView>

    </android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
bashan
  • 3,424
  • 6
  • 37
  • 57
  • `CoordinatorLayout is a super-powered FrameLayout.` Reference: https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.html So it behaves the same way as FrameLayout in general. Hope it gives you an idea, why your list is above toolbar – krossovochkin Sep 23 '15 at 15:51
  • I recommend you to play with the sample apps first. For example with https://github.com/chrisbanes/cheesesquare from ChrisBanes, to get an idea on how new components work – krossovochkin Sep 23 '15 at 15:53
  • Thanks @krossovochkin. I am taking my inspiration from this exact app :) For some reason it behaves differently though most of the things are quite the same. – bashan Sep 23 '15 at 16:02
  • I just changed the: CoordinatorLayout to: FrameLayout and I am having the same issue, so I think it is not directly related with the layout. – bashan Sep 23 '15 at 16:07
  • 1
    Try to add `app:layout_behavior="@string/appbar_scrolling_view_behavior"` to your SwipeRefreshLayout. Reference: http://stackoverflow.com/questions/30624138/android-coordinatorlayout-and-swiperefreshlayout – krossovochkin Sep 23 '15 at 16:09
  • Thanks. Works like a charm :) – bashan Sep 23 '15 at 16:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/90460/discussion-between-bashan-and-krossovochkin). – bashan Sep 23 '15 at 17:58
  • It works great, but for some reason the: property app:layout_scrollFlags="scroll|enterAlways" of the ToolBar doesn't work at all. Any idea? – bashan Sep 23 '15 at 18:20

0 Answers0