0

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 ?

Karesh A
  • 1,731
  • 3
  • 22
  • 47
  • can you describe more – Amit Vaghela Oct 07 '17 at 06:29
  • I have list of menu items, once user selected the items I will mark a button visible. The image shows the visible button. At this time last element of the list view is hidden behind the button. I want to make it on top/scroll more. – Karesh A Oct 07 '17 at 06:34
  • have you check [this](https://stackoverflow.com/questions/33668144/position-view-below-another-view-in-coordinatorlayout-in-android). – paril Oct 07 '17 at 06:37
  • Yes I have added app:layout_anchor="@+id/post_text_layout" and app:layout_anchorGravity="bottom" . still hiding. scroll view is outside appbar. – Karesh A Oct 07 '17 at 06:44

4 Answers4

2

I think this will solve your problem,

 <?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:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fillViewport="true"
        android:background="@android:color/darker_gray">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_alignParentTop="true"
                android:layout_height="match_parent"
                android:layout_above="@+id/ssssss"/>

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

                android:visibility="visible" />

        </RelativeLayout>


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




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

here is the sample output enter image description here

NOTE: you have added android:fitsSystemWindows="true" and so you need android:paddingTop="80dp" in your recycler view.Instead you can follow as in my solution just give android:fillViewport="true" to nestedScrollView and no padding needed for recyclerview. I hope this solves your issue

Velmurugan V
  • 428
  • 4
  • 12
1

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())
nitinkumarp
  • 2,120
  • 1
  • 21
  • 30
0

You should change NestedScrollView by using layout_anchor as below.

<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/colorPrimary"
    app:layout_anchor="@+id/relative_view"
    app:layout_anchorGravity="top">

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


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

It put scrollview on top of your bottom bar as per your aspect.

paril
  • 1,850
  • 2
  • 14
  • 26
0
<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.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"
        android:background="#EAEAEA"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context="example.design.activities.DetailsActivity">

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

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/ssssss"
                android:layout_alignParentTop="true"
                android:paddingTop="80dp" />
        </RelativeLayout>

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


</android.support.design.widget.CoordinatorLayout>
Kajol Chaudhary
  • 257
  • 2
  • 9