Search code examples
androidandroid-layoutandroid-coordinatorlayout

Android Coordinator Layout bottom bar hide inside the list view


The bottom button/some view hides the list view bottom part.

  <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.support.design.widget.AppBarLayout>

         <android.support.v4.widget.NestedScrollView 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:context="example.design.activities.DetailsActivity"
                android:background="@color/grey">

                <android.support.v7.widget.RecyclerView
                    android:paddingTop="80dp"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>


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


        <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="bottom"
                android:gravity="bottom">

                <!-- Add to cart button -->
                <android.support.v7.widget.AppCompatButton
                    android:id="@+id/ssssss"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:padding="20dp"
                    android:text="ADD TO CART"
                    android:backgroundTint="@color/colorPrimary"
                    android:textColor="@color/white"
                    android:layout_alignParentBottom="true"
                    android:visibility="visible" />

            </RelativeLayout>

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

enter image description here

I will make the bottom view visible and invisible based on condition.

How can I adjust my list view to scroll more if the bottom bar is visible ?


Solution

  • You can add android:clipToPadding = "false" in your NestedScrollView. And when you are showing your bottom button you can dynamically add bottom padding for NestedScrollview with value equals to height of your bottom button.

    nestedScrollView.setPadding(yourPadding, yourPadding,yourPadding, btn.getMeasuredHeight())