Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix a layout inside Coordinator Layout?

Currently recycler view and the app bar scrolls . Now I need to fix the relative layout rlProductCheckout to the bottom of the screen even if the recyclerview and app bar scrolls. Current relative layout disappears when I start scrolling, it reappears only when I move back to the start of the list.

content_products_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_products_list">



    <android.support.v7.widget.RecyclerView
        android:id="@+id/rvProductList"
        android:layout_above="@+id/rlProductCheckout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:gravity="center_vertical"
        android:id="@+id/rlProductCheckout"
        android:layout_alignParentBottom="true">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Checkout"/>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_send"
            android:layout_alignParentRight="true"/>

    </RelativeLayout>
</RelativeLayout>

activity_products_layout.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">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/expandedImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@mipmap/prod1"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />


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

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



</android.support.design.widget.CoordinatorLayout>
like image 553
koherent Avatar asked Sep 26 '22 22:09

koherent


1 Answers

Try to wrap the RelativeLayout outside the CoordinatorLayout. Try some this like How to put RelativeLayout inside CoordinatorLayout

like image 141
Shiva Avatar answered Oct 03 '22 03:10

Shiva