Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView is below toolbar

Problem: I have a RecyclerView and a Toolbar in a CoordinatorLayout. The RecyclerView is below the Toolbar but it should not.

enter image description here

Question: How can I achieve that the RecyclerView and the Toolbar have one border?

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fitsSystemWindows="true">

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

    <include
        android:id="@+id/toolbar_main"
        layout="@layout/toolbar"></include>

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

    <FrameLayout
        android:id="@+id/maschinelistcontainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

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

maschine_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:scrollbars="vertical" />

</LinearLayout>
like image 255
jublikon Avatar asked Oct 29 '25 04:10

jublikon


1 Answers

Just add below lines to your parent layout i.e Linearlayout of maschine_fragment.xml

xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"

or else add this line to the Framelayout of activity_main.xml

app:layout_behavior="@string/appbar_scrolling_view_behavior"

It will work for you! :)

like image 154
Hardy'k Avatar answered Oct 30 '25 22:10

Hardy'k



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!