Recyclerview is behind/hidden from Toolbar/Actionbar

Asked

Viewed 436 times

-1

Solution: link

Good evening, guys, how are you? I have a problem and to be clear I took a print to show you:

Print do erro

As you can see the list (Recyclerview) is getting behind while it should be below the Toolbar/Actionbar, I don’t know what I’m doing wrong, but I couldn’t solve this problem, does anyone know the solution? I’m only using the support library and nothing else, the error occurs in both emulator and Android 4.1 and 7 too, both real devices. This Toolbar hides when the user scrolls down the screen, in case when he swipes his finger from the bottom up, but this is not a problem I really set up to work like this.

I’ve researched several ways but I can’t get anything related to this, always comes results of other problems or other features.

If I find the solution I will post here...

Follows 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:id="@+id/cl_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ListContatosActivity">

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv_list"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"/>
    </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_height="wrap_content"
        android:background="@color/bg_cadastro"
        android:layout_width="match_parent">

        <android.support.v7.widget.Toolbar
            android:id="@+id/my_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"/>
    </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

2 answers

1

Opa, you are using as parent view the Relative layout?

If you are using the parent view of Relativelayout, you add the layout_below property in Swiperefreshlayout.

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srl_swipe"
android:layout_below="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
    android:id="@+id/rv_list"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:scrollbars="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"/> 
</android.support.v4.widget.SwipeRefreshLayout>
  • I’m sorry the fault friend I don’t know why I didn’t get XML all if I gave Ctrl+a, but the parent view is a Coordinatorlayout, I’ll edit the question and put the whole XML.

  • The problem was here at Stackoverflow, the parent view had been out of code tags and were not displayed so...

  • Please collaborate with the quality of community content by better elaborating your response. Very short answers will hardly be clear enough to add anything to the discussion. If your response is based on some function or feature of the language/tool, link to the official documentation or reliable material that supports your response. Searching for similar questions in the community can also be interesting to indicate other approaches to the problem.

  • @Andersoncarloswoss his answer was not very big, but it was straight to the point and took me the solution, he did not give a theoretical explanation but even so the answer helped to solve the problem.

1

Before the valuable helping of our colleague Natan Felipe I arrived at the following solution, sought a replacement for the layout_below in the CoordinatorLayout that through ignorance I was already in my XML but in the wrong place through this solution got to the property app:layout_behavior="@string/appbar_scrolling_view_behavior" that was in my RecyclerView I removed his property and I put her in SwipeRefreshLayout and everything worked perfectly. Thank you very much to all.

Browser other questions tagged

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